Skip to content
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

Merged
merged 20 commits into from
May 2, 2024

Conversation

pavel-mikula-sonarsource
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource commented Apr 30, 2024

Review per commit should be easier, as methods were moved to many different places, and few file scoped namespaces were migrated.

IsAnyAttributeIsOverridingChain and GetAllNamedTypes were misplaced in their original commits. There are commits later that fixes these

@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban May 1, 2024
Copy link
Contributor

@sebastien-marichal sebastien-marichal left a 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.

Comment on lines +396 to +400
#if DEBUG
new Action(() => ISymbolExtensionsCommon.GetClassification(fakeSymbol.Object)).Should().Throw<NotSupportedException>();
#else
ISymbolExtensionsCommon.GetClassification(fakeSymbol.Object).Should().Be("symbol");
#endif
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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

@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban May 1, 2024
Copy link

sonarcloud bot commented May 1, 2024

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented May 1, 2024

@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban May 1, 2024
Copy link
Contributor

@sebastien-marichal sebastien-marichal left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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() =>
Copy link
Contributor

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)?

Copy link
Contributor Author

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

@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban May 2, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit ca0f118 into master May 2, 2024
37 checks passed
Best Kanban automation moved this from Review approved to Validate Peach May 2, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the Pavel/SymbolHelper branch May 2, 2024 10:56
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from Validate Peach to Done in Best Kanban May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Best Kanban
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants