Skip to content

Document highlights: Syntax node is not within syntax tree #64398

Description

@Peter-Juhasz

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In VS2026 Insider 11206.111, a message bar appears with an error:
"Feature 'Document highlights' is currently unavailable due to an internal error."

StreamJsonRpc.RemoteInvocationException: Syntax node is not within syntax 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 Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__20`1.MoveNext()
RPC server exception:
System.ArgumentException: Syntax node is not within syntax tree
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.CheckSyntaxNode(CSharpSyntaxNode syntax)
      at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfo(ExpressionSyntax expression, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternHighlighter.<>c__DisplayClass2_0.<HighlightSymbol>b__1(IdentifierNameSyntax i)
      at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
      at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternHighlighter.HighlightSymbol(SemanticModel semanticModel, IMethodSymbol methodSymbol, IList`1 highlightSpans, ISymbol matchingParameter, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternHighlighter.GetHighlights(RouteUsageModel routeUsage, SemanticModel semanticModel, Int32 position, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternHighlighter.GetDocumentHighlights(SemanticModel semanticModel, SyntaxToken token, Int32 position, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.ExternalAccess.AspNetCore.Internal.EmbeddedLanguages.AspNetCoreEmbeddedLanguageDocumentHighlighter.GetDocumentHighlights(Document document, SemanticModel semanticModel, SyntaxToken token, Int32 position, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.TryGetEmbeddedLanguageHighlights(Document document, SemanticModel semanticModel, Int32 position, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsInCurrentProcessAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDocumentHighlightsService.<>c__DisplayClass2_0.<<GetDocumentHighlightsAsync>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)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync[T](Func`2 implementation, CancellationToken cancellationToken)

Expected Behavior

No response

Steps To Reproduce

Move caret to a route parameter in a Minimal API route definition.

public static partial class XEndpoints
{
	public static void MapXEndpoints(this IEndpointRouteBuilder app)
	{
		app.MapPost("/organizations/{organizationId}/y/{yId}/z/{zId}/w/{wId}/load", LoadAsync);
	}
}

Exceptions (if any)

No response

.NET Version

10.0.100

Anything else?

The file is a partial class, endpoints are defined in different files.

Metadata

Metadata

Labels

Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc

Type

Fields

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions