dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.72k stars 3.99k forks source link

Editor: syntax node is not within syntax tree #39296

Open vsfeedback opened 4 years ago

vsfeedback commented 4 years ago

[Happens in 16.4.0-preview-3.0-[29409.185.master]

This issue has been moved from a ticket on Developer Community.


[regression] [worked-in:Not sure about prev, 16.3 works for sure]

  1. Get latest Int Preview Visual Studio.
  2. git clone https://github.com/NuGet/NuGet.Client
  3. Follow the instructions up to configure.ps1
  4. Open NuGet.sln in Visual Studio.

After the solution was fully loaded the moment I started type, a yellow bar popped with, an error occured, see log file. Clicking on that opens the activity log in the default xml viewer.

In there I found the below. Note that there could be other problems, but this error was related to types of issues I was seeing.

<entry>
    <record>2738</record>
    <time>2019/10/11 18:15:44.663</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.AggregateException: One or more errors occurred. ---> 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.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetRelatedFieldSymbolAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetDocumentationFromSymbolAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetQuickInfoItemAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.AsyncQuickInfoSession.<ComputeSourceContentAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.AsyncQuickInfoSession.<UpdateAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.AsyncQuickInfoPresentationSession.<UpdateAsync>d__5.MoveNext()
---> (Inner Exception #0) 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.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetRelatedFieldSymbolAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetDocumentationFromSymbolAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SyntaxTree.VisualStudio.Unity.Documentation.UnityQuickInfoSource.<GetQuickInfoItemAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.AsyncQuickInfoSession.<ComputeSourceContentAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)<---
</description>
  </entry>

Original Comments

Visual Studio Feedback System on 10/11/2019, 08:09 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Visual Studio Feedback System on 10/15/2019, 02:09 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

sharwell commented 4 years ago

I just hit this in 16.6 Preview 3 with a slightly different stack:

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.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.QuickInfo.CSharpSemanticQuickInfoProvider.TryGetNullabilityAnalysis(Workspace workspace, SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.QuickInfo.CommonSemanticQuickInfoProvider.<CreateContentAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.QuickInfo.CommonSemanticQuickInfoProvider.<BuildQuickInfoAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.QuickInfo.CommonQuickInfoProvider.<GetQuickInfoAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.QuickInfo.CommonQuickInfoProvider.<GetQuickInfoAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.QuickInfo.QuickInfoServiceWithProviders.<GetQuickInfoAsync>d__5.MoveNext()
sharwell commented 4 years ago

@JoeRobich just hit this again. Same stack as https://github.com/dotnet/roslyn/issues/39296#issuecomment-616531844

sharwell commented 4 years ago

@JoeRobich I just hit this again. Same stack as https://github.com/dotnet/roslyn/issues/39296#issuecomment-616531844.

sharwell commented 4 years ago

@JoeRobich I just hit this again

ooples commented 2 years ago

@JoeRobich I also got this error using the latest visual studio preview version

at 
Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.CheckSyntaxNode(CSharpSyntaxNode 
syntax)<BR>at 
Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetDeclaredSymbol(VariableDeclaratorSyntax 
declarationSyntax, CancellationToken cancellationToken)<BR>at 
Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetDeclaredSymbolCore(SyntaxNode 
node, CancellationToken cancellationToken)<BR>at 
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.AbstractCodeElement.LookupSymbol()<BR>at 
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.CodeVariable.GetSymbolType()<BR>at 
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.CodeVariable.get_Type()<BR>at 
EnvDTE.CodeVariable.get_Type()<BR>at 
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnTypePopulateMembers(Object 
sender, EventArgs e)<BR>at 
System.CodeDom.CodeTypeDeclaration.get_Members()<BR>at 
Microsoft.VisualStudio.Design.Serialization.CodeDom.MergedCodeDomParser.CodeTypeDeclarationPopulator.OnPopulateMembers(Object 
sender, EventArgs e)<BR>at 
System.CodeDom.CodeTypeDeclaration.get_Members()<BR>at 
Microsoft.WinForms.DesignTools.Client.Loader.RemoteCodeDomDesignerLoader.EnsureInitializeComponentStatementsPopulated()<BR>at 
Microsoft.WinForms.DesignTools.Client.Loader.RemoteCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager 
manager)<BR>at 
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager 
serializationManager)<BR>--- End of stack trace from previous location where 
exception was thrown ---<BR>at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()<BR>at 
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager 
serializationManager)<BR>at 
System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost 
host)