-
Notifications
You must be signed in to change notification settings - Fork 464
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
CA1854 Improve suggested variable name and/or type of the fixer #6022
Comments
I think Roslyn will apply |
Interesting, if that is the case suggesting only explicit type sounds good to me
Did not understood this part, when the reducer would convert to var? |
I'll respond per my understanding of Roslyn code I looked at:
Then it ends up here: and finally and here is the reducer implementation: In short:
|
The reamining work here is:
This was reported in #6287 |
Analyzer
Diagnostic ID: CA1854 Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
Describe the improvement
The fixer now suggests to use
TryGetValue(key, out var value)
, some repos prefer concrete type over var, it would be great to add some improvements to resolve this. Also the variable name value might already defined within the scope, it could suggest a bit modified name likevalue1
when a variable namedvalue
is already defined within the scopeDescribe suggestions on how to achieve the rule
value
and add another option for fixer suggestion: one option with var, another with the concrete typevalue
is already defined within the scope suggest a bit modified name likevalue1
etcAdditional context
Related to dotnet/runtime#70157 (comment)
The text was updated successfully, but these errors were encountered: