-
Notifications
You must be signed in to change notification settings - Fork 468
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
Bunch of fixes for CA1859 #6418
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6418 +/- ##
==========================================
- Coverage 96.15% 96.15% -0.01%
==========================================
Files 1365 1365
Lines 317448 317494 +46
Branches 10263 10269 +6
==========================================
+ Hits 305230 305273 +43
+ Misses 9785 9784 -1
- Partials 2433 2437 +4 |
src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseConcreteTypeTests.cs
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseConcreteTypeAnalyzer.Collector.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseConcreteTypeTests.cs
Outdated
Show resolved
Hide resolved
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.
Overall LGTM, thank you! Will wait for the open question resolved before merge
* When using the ?? operator, the nullable annotation for the left-hand operand is now erased. This prevents the analyzer suggesting to use a replacement nullable type rather than its non-nullable variation. * We no longer suggest to upgrade the type of a local/field/parameter if the symbol is being used to invoke a method that's is an explicit implementation of an interface method. If the user would upgrade the type, the call to that method would no longer work. * Ensure that we never recommend upgrading the signature of a method that implements an interface method. * Don't recommend a method to be upgraded if the method is an implementation of a partial method definition. This is because there might be different implementations of the method with conflicting behavior. Note that if you use #if constructs, the diagnostic may still make recommendations that would break your code since the analyzer only knows about the select #if block. * Remove a field-specific optimization that was designed to speed up the analyzer since it actually broke analysis of fields, yielding bogus analysis results.
@Youssef1313 Yes, all these issues were fixed. |
Thanks @geeknoid. I went ahead and closed the four issues. |
When using the ?? operator, the nullable annotation for the left-hand operand is now erased. This prevents the analyzer suggesting to use a replacement nullable type rather than its non-nullable variation. CA1859 erroneously recommends nullable return type #6413
We no longer suggest to upgrade the type of a local/field/parameter if the symbol is being used to invoke a method that is an explicit implementation of an interface method. If the user would upgrade the type, the call to that method would no longer work. CA1859 improperly handles explicit interface implementations #6416
Ensure that we never recommend upgrading the signature of a method that implements an interface method.
Don't recommend a method to be upgraded if the method is an implementation of a partial method definition. This is because there might be different implementations of the method with conflicting behavior. Note that if you use #if constructs, the diagnostic may still make recommendations that would break your code since the analyzer only knows about the selected #if block. Exclude partial method signatures from CA1859 warnings #6414
Remove a field-specific optimization that was designed to speed up the analyzer, since it actually broke analysis of fields, yielding bogus analysis results. CA1859 erroneously suggests changing return type to one of multiple possible return types #6411