question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XYZ encountered an error and has been disabled + SyntaxTree is not part of the compilation

See original GitHub issue

Somehow the Mediator generator has stopped working on my machine on visual studio 2022 17.6.0 and later versions. Possibly this only happened after an update previously, I am not sure. Everything still works on Rider, so clearly it is something to do with the interaction with the Mediator codegen and visual studio. Can you advise what I can do to diagnose this further?

When I open the solution, I see a lot of “XYZ encountered an error and has been disabled” messages at the top of visual studio. These XYZ are related to various parts of the RefactoringProvider and all have the exception trace as shown below. I also see some features with the same issue and stack trace (CodeLens references … ).

If I remove the Mediator code generator from the solution I do not see any of these issues, but obviously, I can’t initialise the mediator, so nothing works in a useful way.

If I look at the IncrementalMediatorGenerator Analyzer in solution explorer, the spinning wheel continues forever, but nothing is generated.

I have tried reinstalling visual studio and rebooting and disabling resharper … any other suggestions?

StreamJsonRpc.RemoteInvocationException: SyntaxTree is not part of the compilation (Parameter ‘syntaxTree’) at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__1511.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.ValueTask1.get_Result() at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection1.<TryInvokeAsync>d__181.MoveNext() RPC server exception: System.ArgumentException: SyntaxTree is not part of the compilation (Parameter ‘syntaxTree’) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSemanticModel(SyntaxTree syntaxTree, Boolean ignoreAccessibility) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonGetSemanticModel(SyntaxTree syntaxTree, Boolean ignoreAccessibility) at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.IsDiagnosticSuppressed(Diagnostic diagnostic, SuppressMessageInfo& info) at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.ApplySourceSuppressions(Diagnostic diagnostic) at Microsoft.CodeAnalysis.GeneratorDriver.FilterDiagnostics(Compilation compilation, ImmutableArray1 generatorDiagnostics, DiagnosticBag driverDiagnostics, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.GeneratorDriver.RunGeneratorsCore(Compilation compilation, DiagnosticBag diagnosticsBag, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.GeneratorDriver.RunGenerators(Compilation compilation, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.FinalizeCompilationAsync(SolutionState solution, Compilation compilationWithoutGenerators, CompilationTrackerGeneratorInfo generatorInfo, Compilation compilationWithStaleGeneratedTrees, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoFromScratchAsync(SolutionState solution, CompilationTrackerGeneratorInfo generatorInfo, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoAsync(SolutionState solution, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetOrBuildCompilationInfoAsync(SolutionState solution, Boolean lockGate, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetCompilationSlowAsync(SolutionState solution, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.GetMetadataReferenceAsync(ICompilationTracker tracker, ProjectState fromProject, ProjectReference projectReference, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.FinalizeCompilationAsync(SolutionState solution, Compilation compilationWithoutGenerators, CompilationTrackerGeneratorInfo generatorInfo, Compilation compilationWithStaleGeneratedTrees, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoFromScratchAsync(SolutionState solution, CompilationTrackerGeneratorInfo generatorInfo, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoAsync(SolutionState solution, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetOrBuildCompilationInfoAsync(SolutionState solution, Boolean lockGate, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetCompilationSlowAsync(SolutionState solution, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Razor.TagHelperResolver.GetTagHelpersAsync(Project workspaceProject, RazorProjectEngine engine, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.Razor.RemoteTagHelperProviderService.GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, String factoryTypeName, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.Razor.RemoteTagHelperProviderService.GetTagHelpersDeltaCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, String factoryTypeName, Int32 lastResultId, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync[T](Func2 implementation, CancellationToken cancellationToken)

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
martinothamarcommented, Jun 13, 2023

Great, I’m publishing the bugfix in version 2.1.2 as well: https://www.nuget.org/packages/Mediator.SourceGenerator/2.1.2 I’ll revisit the “correct” location in a future refarctoring, as there are some big changes to the source generation process coming up

1reaction
panoukos41commented, Jun 13, 2023

Hey thanks for the investigation, I wanted to dig too but didnt have as much time and restarting VS doesn’t help 😛, I am happy the requests I left for later actually helped!!

It works as expected now, thanks again 😄 !!

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS 17.6.2 "SyntaxTree is not part of the compilation" error ...
I was debugging and editing a fluent-syntax LINQ expression with some casts and DataRowVersion checks when Visual Studio displayed the error ...
Read more >
"SyntaxTree is not part of the compilation" reported when ...
"SyntaxTree is not part of the compilation" reported when applying SuppressMessage to generator diagnostics - Developer Community.
Read more >
Cannot get SyntaxTree from Compilation object
I think the issue is that .net framework projects have their source files paths within their .csproj. And opening project works right away....
Read more >
Error with Unity and Visual Studio Bridge (VS project not ...
This issue seems to be caused by an outdated .dll being leftover from an older version in the project. Please try deleting UnityVS....
Read more >
JsonSourceGenerator throwing exceptions after edit ...
SyntaxTree is not part of the compilation Parameter name: syntaxTreeat Microsoft.CodeAnalysis.CSharp.CSharpCompilation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found