No IDE0060 for unused parameter in partial method implementation#63530
No IDE0060 for unused parameter in partial method implementation#63530mavasani merged 2 commits intodotnet:mainfrom
Conversation
...rsAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs
Show resolved
Hide resolved
Youssef1313
left a comment
There was a problem hiding this comment.
Consider adding a test with partial definition without implementation.
Just did. |
1f76643 to
06d2f0b
Compare
| method.IsVirtual || | ||
| method.IsOverride || | ||
| method.PartialImplementationPart != null || | ||
| method.PartialDefinitionPart != null || |
There was a problem hiding this comment.
I don't know, but I feel the check is too strong.
There was a problem hiding this comment.
Given that
- a partial method definition might be generated by some tool, with a parameter list as part of its signature
- the corresponding implementation must have the same signature
I believe it's pointless to run the IDE0060 rule on the implementation (i.e. when method.PartialDefinitionPart != null ).
After all, if any of the parameters are unused by the implementation, what can the developer do? They probably have no control over the autogenerated definition and the implementation's signature must match the definition's...
There was a problem hiding this comment.
I think we should specifically check for generated code. This check can probably be easier when #63447 is merged
There was a problem hiding this comment.
I didn't know about this upcoming IsGeneratedCode flag. You're right, waiting for it sounds like a good idea.
There was a problem hiding this comment.
I am not sure if IsGeneratedCode check helps here. The callback would only be made for non-generated code for IDE0060 analyzer, and you can't check whether or not the other partial symbol is generated or not from this callback.
|
@louis-z Can you please resolve merge conflicts? |
If a partial method implementation does not use a parameter, do not generate an IDE0060 diagnostic. Also, fix minor typos (Unsued vs Unused)
06d2f0b to
466493e
Compare
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
If a partial method implementation does not use a parameter, do not generate an IDE0060 diagnostic.
Also, fix minor typos ("Unsued" vs "Unused")
Fixes #57814