SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
787 stars 226 forks source link

Third party issues on Razor templates are not imported #8737

Open andrei-epure-sonarsource opened 8 months ago

andrei-epure-sonarsource commented 8 months ago

We analyze Razor templates (.razor, .cshtml files) and we should import third party issues.

Repro streps

  1. Clone https://github.com/dotnet/blazor-samples
  2. Scan /blazor-samples/7.0/BlazorServerEFCoreSample in verbose mode
    cd blazor-samples\7.0\BlazorServerEFCoreSample
    dotnet sonarscanner begin /k:"demo" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="sqa_TOKEN" /d:sonar.verbose=true
    dotnet build .\BlazorServerEFCoreSample.csproj
    dotnet sonarscanner end /d:sonar.login="sqa_TOKEN"

The build logs show:

blazor-samples\7.0\BlazorServerEFCoreSample\Shared\ContactRow.razor(50,20): warning BL0007: Component parameter 'BlazorServerEFCoreSample.Shared.ContactRow.CurrentContact' should be auto property [C:\con ferences\2024_blazor_webinar\blazor-samples\7.0\BlazorServerEFCoreSample\BlazorServerEFCoreSample.csproj] blazor-samples\7.0\BlazorServerEFCoreSample\Pages\Index.razor(98,16): warning BL0007: Component parameter 'BlazorServerEFCoreSample.Pages.Index.Page' should be auto property [C:\conferences\2024_blazor_w ebinar\blazor-samples\7.0\BlazorServerEFCoreSample\BlazorServerEFCoreSample.csproj]

And the debug logs show:

20:21:11.882 DEBUG: Failed to retrieve the real full path for 'Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Shared_ContactRow_razor.g.cs' 20:21:11.883 DEBUG: Skipping issue BL0007, input file not found or excluded: Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Shared_ContactRow_razor.g.cs 20:21:11.883 DEBUG: Failed to retrieve the real full path for 'Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_razor.g.cs' 20:21:11.884 DEBUG: Skipping issue BL0007, input file not found or excluded: Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_razor.g.cs

Expected: BL0007 is imported as third party issue. Actual: no third party issues are imported on Razor templates.

Dotnet version: 8.0.200-preview.23624.5 (ok, maybe I should install the LTS released version) Analyzer version: 9.19 SonarScanner for MSBuild 5.15

andrei-epure-sonarsource commented 8 months ago

Probably related to https://github.com/dotnet/roslyn/issues/51773

costin-zaharia-sonarsource commented 8 months ago

The paths are not indexed so the issues cannot be imported. This should be fixed by https://github.com/dotnet/roslyn/issues/71449