-
Notifications
You must be signed in to change notification settings - Fork 223
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
UTs: run on dotnet 8.0.5 #9295
Conversation
<p>Current count: @currentCount</p> <!-- Not counted --> | ||
|
||
@currentCount <!-- +1 --> | ||
@currentCount <!-- Not counted --> |
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.
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 }); |
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.
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 }); |
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.
See also the comment from CSharpExecutableLinesMetricTest.cs
. Arguments are no longer considered executable lines.
ba877c5
to
3e904d8
Compare
@@ -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")); |
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 old library is no longer present. The source generators are now part of the Microsoft.CodeAnalysis.Razor.Compiler.dll
.
- the mapping is now fixed
@* ^^^^^^^^^ *@ | ||
@* ^^ Secondary@-1 *@ |
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 locations are now correct 🎉
- task: UseDotNet@2 | ||
displayName: Use .NET | ||
inputs: | ||
packageType: 'sdk' | ||
version: 8.0.300 | ||
|
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.
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
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.
Left few comments/questions
analyzers/tests/SonarAnalyzer.Test/Rules/Utilities/MetricsAnalyzerTest.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/Utilities/MetricsAnalyzer/Razor.razor
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.Test/TestCases/Utilities/MetricsAnalyzer/Razor.razor
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.TestFramework.Test/TestCases/DummyExpressions.razor
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.
LGTM!
|
|
dotnet 8.0.5 introduced breaking changes when generating code for Razor files.
This PR updates our pipeline to:
Fixes: #9291