Skip to content

Analyzers throw "SyntaxTree is not part of the compilation" exceptions #543

@alainbryden

Description

@alainbryden

I cannot get the following 6 warnings to go away when running code analysis on this project using DurableTask.

Analyzer 'Microsoft.DurableTask.Analyzers.Orchestration.DateTimeOrchestrationAnalyzer' threw an exception of type 'System.ArgumentException' with message 'SyntaxTree is not part of the compilation (Parameter 'syntaxTree')'.
Exception occurred with following context:
Compilation: <Project Name>
SyntaxTree: C:\Users\abryden\git\<project path>\TaskDispatcher.cs
SyntaxNode: [Function(nameof(OrchestrateDispatch ... [MethodDeclarationSyntax]@[2335..3145) (66,4)-(80,5)

System.ArgumentException: SyntaxTree is not part of the compilation (Parameter 'syntaxTree')
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSemanticModel(SyntaxTree syntaxTree, SemanticModelOptions options)
   at Microsoft.DurableTask.Analyzers.Orchestration.MethodProbeOrchestrationVisitor.FindInvokedMethods(SemanticModel semanticModel, SyntaxNode callerSyntax, IMethodSymbol callerSymbol, String rootOrchestration, Action`1 reportDiagnostic)
   at Microsoft.DurableTask.Analyzers.Orchestration.OrchestrationAnalyzer`1.<>c__DisplayClass0_0.<Initialize>b__1(SyntaxNodeAnalysisContext ctx)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
-----

Suppress the following diagnostics to disable this analyzer: DURABLE0001

I get one of these for each of DURABLE0001, DURABLE0002, DURABLE0003, DURABLE0004, DURABLE0005, DURABLE0006 - each the same except for the Analyzer name at the start of the message.

IDE: Microsoft Visual Studio Professional 2022 (64-bit) - Current - Version 17.14.21 (November 2025)

I've tried things like restarting, reinstalling the latest VS2022, removing and re-adding the nuget package Microsoft.Azure.Functions.Worker.Extensions.DurableTask, explicitly installing the Microsoft.DurableTask.Analyzers package (there's only version 0.1.0, so I can't test upgrading/downgrading this).

I've searched and found similar issues to "SyntaxTree is not part of the compilation" seemingly resolved by visual studio updates (e.g. https://developercommunity.visualstudio.com/t/Feature-Semantic-classification-is-cur/10370922), as well as previously fixed Analyzer issues (e.g. Azure/azure-functions-durable-extension#1320), so perhaps this is a new issue in a similar vein?

Thanks for your help, and sorry if this turns out not to be an issue related to this project.

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