Skip to content

NET-3376 Fix S6930 AD0001: Issue on template / code files for blazor #9789

Closed

Description

@acfaruk

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

Activity

  1. changed the title [-]Fix AD0001: S6930[/-] [+]Fix AD0001: S6930 Issue on template / code files for blazor[/+] on Feb 19, 2026
  2. changed the title [-]Fix AD0001: S6930 Issue on template / code files for blazor[/-] [+]Fix S6930 AD0001: Issue on template / code files for blazor[/+] on Mar 11, 2026
  3. changed the title [-]Fix S6930 AD0001: Issue on template / code files for blazor[/-] [+]NET-3376 Fix S6930 AD0001: Issue on template / code files for blazor[/+] on Mar 11, 2026
  4. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    Internal ticket NET-3376

  5. alex-meseldzija-sonarsource commented on Mar 11, 2026

    @alex-meseldzija-sonarsource
    Contributor

    Hi @acfaruk,

    Thanks for reporting this! I can confirm that this is an AD0001.
    We will try to fix it soon.

  6. alex-meseldzija-sonarsource commented on Mar 17, 2026

    @alex-meseldzija-sonarsource
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExceptions and blocking issues during analysis.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions