-
Notifications
You must be signed in to change notification settings - Fork 222
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
Decompose SymbolHelper into dedicated extension classes #9229
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.
I have seen variables renamed/switched which was a bit confusing.
Also, extension method invocation in the UT where changes are not always for the same way, which, IMO, makes the code inconsistent.
analyzers/tests/SonarAnalyzer.Test/Extensions/ITypeSymbolExtensionsTest.cs
Outdated
Show resolved
Hide resolved
#if DEBUG | ||
new Action(() => ISymbolExtensionsCommon.GetClassification(fakeSymbol.Object)).Should().Throw<NotSupportedException>(); | ||
#else | ||
ISymbolExtensionsCommon.GetClassification(fakeSymbol.Object).Should().Be("symbol"); | ||
#endif |
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.
What is the point of the #if DEBUG .. #else .. #endif
?
Do we run UTs in both Debug and Release?
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.
The implementation behaves differently under debug and release builds
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.
I mean, if we run UTs in both configurations (Debug & Release), it is fine. Otherwise, I don't see the point to have these.
Do we run UTs in both configurations in the CI?
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.
We run release in CI and debug locally
analyzers/tests/SonarAnalyzer.Test/Extensions/ITypeSymbolExtensionsTest.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/Extensions/ISymbolExtensionsTest.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/Extensions/IPropertySymbolExtensionsTest.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.VisualBasic/Extensions/SyntaxNodeExtensions.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/Trackers/BuilderPatternConditionTest.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.Shared/Extensions/SyntaxNodeExtensions.cs
Outdated
Show resolved
Hide resolved
Quality Gate passed for 'Sonar .NET Java Plugin'Issues Measures |
Quality Gate passed for 'SonarAnalyzer for .NET'Issues Measures |
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!
The remaining comments are not blocking the merge.
using ExtensionsCommon = common::SonarAnalyzer.Extensions.SyntaxNodeExtensions; | ||
using ExtensionsCS = csharp::SonarAnalyzer.Extensions.SyntaxNodeExtensionsCSharp; | ||
using ExtensionsVB = vbnet::SonarAnalyzer.Extensions.SyntaxNodeExtensionsCSharp; | ||
using ExtensionsShared = csharp::SonarAnalyzer.Extensions.SyntaxNodeExtensionsShared; |
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.
For my understanding, shared projects behave as they were part of the assembly they are imported in?
That's why we have the chasrp::
namespace prefix here?
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.
Exactly. There exists vbnet:SonarAnalyzer.Extensions.SyntaxNodeExtensionsShared
AND csharp:SonarAnalyzer.Extensions.SyntaxNodeExtensionsShared
.
We're testing just one of them.
IEnumerable<(SyntaxNode node, string name)> GetCSharpNodes() => | ||
snippet.GetNodes<CSharpSyntax.InvocationExpressionSyntax>() | ||
.Select(n => ((SyntaxNode)n, CSharpSyntaxNodeExtensions.GetIdentifier(n.Expression)?.ValueText)); | ||
IEnumerable<(SyntaxNode Node, string Name)> GetCSharpNodes() => |
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 is not raising T0003 (ValueTuple)?
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.
No, because it's a test code. See
public AvoidValueTuple() : base("T0003", "Do not use ValueTuple in the production code due to missing System.ValueTuple.dll.", SourceScope.Main) { } // It's not a problem in UTs |
Review per commit should be easier, as methods were moved to many different places, and few file scoped namespaces were migrated.
IsAnyAttributeIsOverridingChain
andGetAllNamedTypes
were misplaced in their original commits. There are commits later that fixes these