-
Notifications
You must be signed in to change notification settings - Fork 470
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
Fix analyzers/tests for non-local diagnostics #6690
Conversation
Fixes dotnet#6598 - Move to latest Microsoft.CodeAnalysis package for unit tests - Fix analyzers reporting non-local diagnostics - Add comments to tests where `CodeFixTestBehaviors.SkipLocalDiagnosticCheck` cannot be removed - Also fixed a code fixer relying on implicit tracking node functionality, which fails after moving to latest MS.CA bits.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6690 +/- ##
=======================================
Coverage 96.39% 96.39%
=======================================
Files 1379 1379
Lines 322416 322431 +15
Branches 10461 10464 +3
=======================================
+ Hits 310784 310803 +19
+ Misses 9139 9136 -3
+ Partials 2493 2492 -1 |
.../Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs
Show resolved
Hide resolved
.../Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs
Show resolved
Hide resolved
!fieldInitializerValue.ConstantValue.HasValue || | ||
!context.Options.MatchesConfiguredVisibility(DefaultRule, lastField, context.Compilation, defaultRequiredVisibility: SymbolVisibilityGroup.Internal | SymbolVisibilityGroup.Private) || | ||
!context.Options.MatchesConfiguredModifiers(DefaultRule, lastField, context.Compilation, defaultRequiredModifiers: SymbolModifiers.Static)) | ||
context.RegisterOperationAction(context => |
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.
💡 This will be called a large number of times. It would be better to declare a Action<OperationAnalysisContext>
in the containing scope and pass that in instead of allocating a new delegate for every field.
@@ -17,6 +17,14 @@ namespace Microsoft.NetCore.Analyzers.Runtime.UnitTests | |||
{ | |||
public class SealInternalTypesTests | |||
{ | |||
// NOTE: 'SealInternalTypes' analyzer reports a compilation end diagnostic. | |||
// Code fixes are not yet supported for compilation end diagnostics, |
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.
Code fixes are not yet supported for compilation end diagnostics
❔ Does this apply to dotnet-format?
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.
Does this apply to dotnet-format?
I am not sure.
End Sub | ||
|
||
Private Shared Function HasEqualityOperator(type As INamedTypeSymbol) As Boolean | ||
For Each method In type.GetMembers().OfType(Of IMethodSymbol) |
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.
💡 Would be better to iterate over GetMembers()
and have the OfType<IMethodSymbol>()
check in the body.
We did doc this somewhere, right? Given the number of changes in roslyn itself, and here, this will def impact the ecossytem. The wins are so great, it's def worth it. I just want to make sure we did doc this so we can point people to the issue when they run into it on their end. thanks! |
Merging the PR as-is to unblock Cyrus. I’ll address @sharwell’s feedback with a follow up PR later today. |
Address remaining feedback from #6690
Fixes #6598
Recommended to review ignoring whitespace differences
CodeFixTestBehaviors.SkipLocalDiagnosticCheck
cannot be removed