Skip to content

Syntax tree doesn't belong to the underlying 'Compilation' #80768

@winscripter

Description

@winscripter

Version Used: Visual Studio 2026 Insiders [11111.16]

Steps to reproduce:
Simply opening C# source files.

Actual behavior:
VS displays a banner, "Diagnostics analyzer runner has been disabled due to an internal error" and the exception stack trace is as follows:

StreamJsonRpc.RemoteInvocationException: Syntax tree doesn't belong to the underlying 'Compilation'. (Parameter 'tree')
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__171`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__20`1.MoveNext()
RPC server exception:
System.ArgumentException: Syntax tree doesn't belong to the underlying 'Compilation'. (Parameter 'tree')
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyTree(SyntaxTree tree)
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalysisResultAsync(SyntaxTree tree, Nullable`1 filterSpan, ImmutableArray`1 analyzers, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.<>c__DisplayClass35_0.<<AnalyzeInProcessAsync>g__GetAnalysisResultAsync|2>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.<>c__DisplayClass35_0.<<AnalyzeInProcessAsync>g__AnalyzeAsync|0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.AnalyzeInProcessAsync(DocumentAnalysisScope documentAnalysisScope, Project project, CompilationWithAnalyzers compilationWithAnalyzers, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.DocumentAnalysisExecutor.<>c__DisplayClass12_0.<<ComputeDiagnosticsInProcessAsync>g__GetAnalysisResultInProcessAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.DocumentAnalysisExecutor.<>c__DisplayClass12_0.<<ComputeDiagnosticsInProcessAsync>g__GetCompilerAnalyzerDiagnosticsInProcessAsync|2>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.DocumentAnalysisExecutor.<>c__DisplayClass12_0.<<ComputeDiagnosticsInProcessAsync>g__GetSyntaxDiagnosticsInProcessAsync|3>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.DocumentAnalysisExecutor.ComputeDiagnosticsInProcessAsync(DiagnosticAnalyzer analyzer, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.ComputeDocumentDiagnosticsCoreInProcessAsync(DocumentAnalysisExecutor executor, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.<>c__DisplayClass43_0.<<ComputeDiagnosticsInProcessAsync>g__ComputeDocumentDiagnosticsAsync|0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.ComputeDiagnosticsInProcessAsync(TextDocument document, Nullable`1 range, ImmutableArray`1 allAnalyzers, ImmutableArray`1 syntaxAnalyzers, ImmutableArray`1 semanticSpanAnalyzers, ImmutableArray`1 semanticDocumentAnalyzers, Boolean incrementalAnalysis, Boolean logPerformanceInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.GetDiagnosticsForSpanInProcessAsync(TextDocument document, Nullable`1 range, DiagnosticIdFilter diagnosticIdFilter, Nullable`1 priority, DiagnosticKind diagnosticKind, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService.GetDiagnosticsForSpanAsync(TextDocument document, Nullable`1 range, DiagnosticIdFilter diagnosticIdFilter, Nullable`1 priority, DiagnosticKind diagnosticKind, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass12_0.<<GetDiagnosticsForSpanAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)

It's not pleasant since the appearance of the banner causes the entire UI to jump down, causing disruption.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions