-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update S927: C#: parameter names should match base declaration and other partial definitions #534
Conversation
4e78abd
to
0bd46d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like you are not covering interfaces definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments to consider, but LGTM (assuming you address Amaury's comment).
"issues": [ | ||
{ | ||
"id": "S927", | ||
"message": "Rename parameter 'pipelineItem' to 'syncDelegate'.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at the rule - perhaps tweak the message to give some context:
"Rename parameter '{0}' to '{1}' to match the inhertited parameter name."
(or something similar)
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
else | ||
{ | ||
// do nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that empty else? I know this is there intentionally to make point, but do we need that?
Perhaps rewrite to somethig like that - WDYT?
var parameters = methodSymbol?.PartialDefinitionPart?.Parameters ?? methodSymbol?.OverriddenMethod?.Parameters;
VerifyParameters(c, methodSyntax, expectedParameters: parameters);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, but with the message argument I cannot do it nicely... See the updated code.
private static void VerifyParameters(SyntaxNodeAnalysisContext context, | ||
MethodDeclarationSyntax methodSyntax, IList<IParameterSymbol> expectedParameters) | ||
{ | ||
var implementationParameters = methodSyntax.ParameterList.Parameters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know the collections are always the same length?
[Optional] you could try using Zip the way we did in MethodOverloadOptionalParameter.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise the methods will not be matched as overrides... I replaced the loop with Zip.
…her partial definitions
0bd46d4
to
3b7543a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #516