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

UTs: run on dotnet 8.0.5 #9295

Merged
merged 6 commits into from
May 17, 2024
Merged

Conversation

costin-zaharia-sonarsource
Copy link
Member

@costin-zaharia-sonarsource costin-zaharia-sonarsource commented May 17, 2024

dotnet 8.0.5 introduced breaking changes when generating code for Razor files.

This PR updates our pipeline to:

  • run UTs on 8.0.5
  • describe the new behavior

Fixes: #9291

Comment on lines +896 to +898
<p>Current count: @currentCount</p> <!-- Not counted -->

@currentCount <!-- +1 -->
@currentCount <!-- Not counted -->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These references were initially considered "executable code" because the generated code described them as function calls that could be mapped back to the razor file.

Now, currentCount it's just an argument. It can be mapped back, but we usually don't consider arguments as executable code.

The new behavior is consistent with how we compute executable code lines for .cs files.

@@ -69,14 +69,14 @@ public class MetricsAnalyzerTest
var metrics = messages.Single(x => x.FilePath.EndsWith(RazorFileName));

metrics.ClassCount.Should().Be(1);
metrics.CodeLine.Should().BeEquivalentTo(new[] { 3, 5, 8, 10, 13, 15, 16, 17, 19, 22, 23, 24, 26, 28, 29, 32, 33, 34, 36, 37, 39, 40, 43 });
metrics.CodeLine.Should().BeEquivalentTo(new[] { 2, 1, 3, 5, 8, 10, 13, 15, 16, 17, 19, 22, 23, 24, 26, 28, 29, 32, 33, 34, 36, 37, 39, 40, 43 });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A documented FN was fixed. Now 1 and 2 lines are correctly identified as "code lines".

metrics.CognitiveComplexity.Should().Be(3);
metrics.Complexity.Should().Be(4);
metrics.ExecutableLines.Should().BeEquivalentTo(new[] { 3, 5, 13, 15, 17, 24, 28, 29, 32, 36, 39, 43 });
metrics.ExecutableLines.Should().BeEquivalentTo(new[] { 13, 15, 28, 29, 32, 36 });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also the comment from CSharpExecutableLinesMetricTest.cs. Arguments are no longer considered executable lines.

@@ -26,20 +26,20 @@ namespace SonarAnalyzer.TestFramework.Test.Common;
public class SourceGeneratorProviderTest
{
private static AnalyzerFileReference RazorSourceGenerator =>
SourceGeneratorProvider.SourceGenerators.Single(x => x.FullPath.EndsWith("Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators.dll"));
SourceGeneratorProvider.SourceGenerators.Single(x => x.FullPath.EndsWith("Microsoft.CodeAnalysis.Razor.Compiler.dll"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old library is no longer present. The source generators are now part of the Microsoft.CodeAnalysis.Razor.Compiler.dll.

- the mapping is now fixed
Comment on lines +3 to +4
@* ^^^^^^^^^ *@
@* ^^ Secondary@-1 *@
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locations are now correct 🎉

Comment on lines +251 to +256
- task: UseDotNet@2
displayName: Use .NET
inputs:
packageType: 'sdk'
version: 8.0.300

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A temporary step is needed to force the usage of the latest SDK (8.0.300).

This should move to our VM image generation but it will be handled as a separate task. See: https://trello.com/c/RF07g3Nk/1370-update-vms-to-use-dotnet-805

Copy link
Contributor

@CristianAmbrosini CristianAmbrosini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments/questions

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

@CristianAmbrosini CristianAmbrosini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

sonarcloud bot commented May 17, 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 17, 2024

Quality Gate Passed Quality Gate passed for 'SonarAnalyzer for .NET'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@costin-zaharia-sonarsource costin-zaharia-sonarsource merged commit f35e9fa into master May 17, 2024
29 checks passed
Best Kanban automation moved this from Review approved to Validate Peach May 17, 2024
@costin-zaharia-sonarsource costin-zaharia-sonarsource deleted the costin/update-dotnet branch May 17, 2024 13:23
@costin-zaharia-sonarsource costin-zaharia-sonarsource moved this from Validate Peach to Done in Best Kanban May 22, 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.

TestFramework: razor analysis is not supported starting with dotnet 8.0.5
2 participants