Description
Hello!
We've identified a regression in the sonar-dotnet analyzer when it comes to issue location mapping from generated code to Razor files within adhoc workspaces after updating to .NET SDK 9.0.301.
Here's how the issue manifests:
From 8.0.5 up to 9.0.106
<p>The solution to all problems is: @(RaiseHere(21))</p> @*Correct locations*@
@* ^^^^^^^^^ *@
@* ^^ Secondary@-1 *@
With 9.0.301
<p>The solution to all problems is: @(RaiseHere(21))</p> @*Wrong locations*@
@* ^^^^^^^^^ *@
@* ^^ Secondary@-1 *@
It appears there's a change in the auto-generated code, as shown in the image below, which is causing the issue location to be shifted to the right.
Specifically, the issue location has been shifted right by the same number of characters as the __builder.AddContent(2,
length.
Based on our experiments, this problem doesn't seem to occur in non-adhoc workspaces (I'll update this ticket if we find new information).
One last question:
We've also noticed that issues previously present in MSBuild workspaces no longer exist (e.g., issue mapping for nested expressions, as seen here). One key difference is the use of enhanced line directives that include an offset. Does this offset now consistently match the user-written expression in the source files, or has something else changed? I am asking this because, based on this comment, my understanding is that this wasn't the case.
Regression Details:
You can see the details of this regression in these diffs: here and here. These show that test issue locations that were fixed with .NET 8.0.5 have now reverted to being shifted.
Thanks a lot for your help!
Thanks a lot!