-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bail out on reporting unused parameter diagnostic for special paramet… #32883
Conversation
…er names We ignore parameter names that start with an underscore and are optionally followed by an integer, such as '_', '_1', '_2', etc. This allows bailing out on unused parameters for methods that need a specific signature and are forced to have these parameters. This also serves as a convenient way to suppress instances of unused parameter diagnostic without disabling the diagnostic completely. Fixes dotnet#32851 Fixes dotnet#32228
Tagging @bartdesmet @YairHalberstadt |
Looks great! |
Tagging @jinujoseph @vatsalyaagrawal for approval and @dotnet/roslyn-ide for further review(s). |
So we are creating a naming convention in IDE layer to mark discard parameters w/o compiler support for analysis purposes? Is this something we intend to support officially, or just as a temporary workaround until dotnet/csharplang#2180 is finalized? |
Looks like a reasonable long term solution to me given we don’t expect code bases with wide usages of _1, _2, etc as parameter names. |
@genlu Any further comments? Thanks! |
I'm fine with this approach, just two suggestions:
Also, we will need to mention this in the VS document when it's up |
The existing diagnostic is already an info diagnostic, and it seems likely this will just be noise. Lets do this only if we find real customer code bases where such parameter naming is used widely enough for used parameter names.
I think this case is extremely rare, and we see more folks filing such issues, we can change the message. I don't want to make the diagnostic message unnecessarily complex for a rare case. Hopefully, language will also be modified soon enough to allow real discard parameters and we wouldn't need to do anything here. |
Bail out on reporting unused parameter diagnostic for special paramet…
…er names
We ignore parameter names that start with an underscore and are optionally followed by an integer, such as
_
,_1
,_2
, etc.This allows bailing out on unused parameters for methods that need a specific signature and are forced to have these parameters. This also serves as a convenient way to suppress instances of unused parameter diagnostic without disabling the diagnostic completely.
Fixes #32851
Fixes #32228