Repository navigation
NET-3376 Fix S6930 AD0001: Issue on template / code files for blazor #9789
Copy link
Copy link
Closed
Labels
BugExceptions and blocking issues during analysis.Exceptions and blocking issues during analysis.
Description
Description
Running the analyzers on a generated razor / razor.cs file combo in a blazor project get's me this:
12:47:07.867 4:7>CSC : warning AD0001: Analyzer 'SonarAnalyzer.CSharp.Rules.BackslashShouldBeAvoidedInAspNetRoutes' threw an exception of type 'System.ArgumentException' with message 'Syntax node is not within syntax tree'. [/home/vsts/work/1/s/src/Project/Project.csproj]
Exception occurred with following context: (TaskId:900)
Compilation: Project (TaskId:900)
SyntaxTree: /home/vsts/work/1/s/src/Project/obj/Release/net10.0/Microsoft.CodeAnalysis.Razor.Compiler/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/SomeFolder_OtherFolder_SomeComponent_razor.g.cs (TaskId:900)
SyntaxNode: _elapsedTime [ArgumentSyntax]@[5942..5954) (167,110)-(167,122) (TaskId:900)
System.ArgumentException: Syntax node is not within syntax tree (TaskId:900)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.CheckSyntaxNode(CSharpSyntaxNode syntax) (TaskId:900)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetTypeInfo(ExpressionSyntax expression, CancellationToken cancellationToken) (TaskId:900)
at SonarAnalyzer.CSharp.Core.Syntax.Extensions.MemberAccessExpressionSyntaxExtensionsShared.IsPtrZero(MemberAccessExpressionSyntax memberAccess, SemanticModel model) (TaskId:900)
at SonarAnalyzer.Core.Trackers.ConstantValueFinder`2.FindConstant(SyntaxNode node, HashSet`1 visitedVariables) (TaskId:900)
at SonarAnalyzer.Core.Rules.BackslashShouldBeAvoidedInAspNetRoutesBase`1.Check(SonarSyntaxNodeReportingContext c) (TaskId:900)
at SonarAnalyzer.Core.AnalysisContext.SonarCompilationStartAnalysisContext.<>c__DisplayClass18_0`1.<RegisterNodeAction>b__0(SyntaxNodeAnalysisContext x) (TaskId:900)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) (TaskId:900)
When combining the files (by using @ code inside the razor file) I don't get this issue anymore... I also tried marking the generated files as generated in the editorconfig and settings the analyzer S6930 to None in it for those files, but that didn't work either.
Scanner: SonarScanner for .NET via Azure DevOps SonarCloudPrepare@3 / SonarCloudAnalyze@3
Analyzer: SonarAnalyzer.CSharp (rule S6930), exact package version not pinned in repo because SonarCloud injects it.
Environment:
OS agent: ubuntu-latest
.NET SDK: 10.0.103
Project target: net10.0
Reproducer
Product and Version
SonarCloud
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugExceptions and blocking issues during analysis.Exceptions and blocking issues during analysis.
Activity
[-]Fix AD0001: S6930[/-][+]Fix AD0001: S6930 Issue on template / code files for blazor[/+][-]Fix AD0001: S6930 Issue on template / code files for blazor[/-][+]Fix S6930 AD0001: Issue on template / code files for blazor[/+][-]Fix S6930 AD0001: Issue on template / code files for blazor[/-][+]NET-3376 Fix S6930 AD0001: Issue on template / code files for blazor[/+]github-actions commentedon Mar 11, 2026
Internal ticket NET-3376
alex-meseldzija-sonarsource commentedon Mar 11, 2026
Hi @acfaruk,
Thanks for reporting this! I can confirm that this is an AD0001.
We will try to fix it soon.
alex-meseldzija-sonarsource commentedon Mar 17, 2026
Hi @acfaruk ,
We have fixed this in the latest release of our analyzers. It is available now on SonarQube Cloud and will be available in the next SonarQube Server release.