-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[StyleCleanUp] Addressing CA warnings Part 2 #10186
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
[StyleCleanUp] Addressing CA warnings Part 2 #10186
Conversation
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
Is there a reason all of the Format arguments that were string versions of type names, method names or other parameters/variables were not converted to nameof as well? Tons of examples on just the edited lines in this PR. Examples: And many more. |
@DanFTRX Read the implementation notes on https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1507 to understand what is the reason. Especially the note about parameter names required for the analyzer to fire. |
@h3xds1nz It seems a lot like following the word of the rules rather than the spirit of the rules only correct the strings that caused this warning. The point of the diagnostic is that using nameof improves code maintainability in cases where the code element may be renamed in the future, but the string literal is mistakenly not renamed. That motivation applies equally to these other string constants even if the particular analyzer didn't happen to highlight them. I would posit that a pass on these other string constants should also be done otherwise this particular rule is just theatre. |
@DanFTRX Analyzers don't catch everything, likely won't for a while as its a static analysis too, or they catch too much. Of course I agree with you that a pass on the occurences that the analyzer does not catch should be done as well, but does not necessarily need to be done in this PR, where the clear scope was to compile with Sorry if you've misunderstood my reply but given you've asked for a reason behind "why those weren't converted as well", I merely answered that part. |
Ah understood, the answer wasn't "we don't want to" but rather "the scope of this PR was limited". That makes sense. |
Fixes #10294
Description
This work is a part of our initiative to set code-style guidelines, align WPF and WinForms, and ensure PR standards with respect to styles. This in turn will help us in better maintainability and readability of the repo overall. The changes follow up from the PR #10080 and references to the issue #10017.
The current changes address the following Errors/Warnings in the src folder of WPF:
A good way to go about reviewing this is to go commit by commit which pans over individual errors/warnings and hence easing out the overall understanding.
Customer Impact
None
Regression
None
Testing
Local Build Pass
The current set of changes looks fairly mechanical and probably don't need a Test Pass, but these set of PRs can be clubbed to do so at a later stage.
Risk
Low
Microsoft Reviewers: Open in CodeFlow