-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
Description
Description
All orchestration analyzers (DateTimeOrchestrationAnalyzer, DelayOrchestrationAnalyzer, ThreadTaskOrchestrationAnalyzer, etc.) throw System.ArgumentNullException with message Value cannot be null. (Parameter 'node') when AddOrchestratorFunc is called with an inline lambda inside a foreach loop that captures a loop-scoped variable.
This affects both Microsoft.DurableTask.Analyzers v0.2.0 and v0.3.0.
Steps to Reproduce
- Clone the minimal repro: https://github.com/kshyju/DurableTaskAnalyzersBugRepro
- Run
dotnet build
The repro project uses <TreatWarningsAsErrors>true</TreatWarningsAsErrors> so the AD0001 warnings surface as build errors.
Minimal Repro Code
var builder = FunctionsApplication.CreateBuilder(args);
string[] names = ["A", "B"];
builder.ConfigureDurableWorker().AddTasks(tasks =>
{
foreach (string name in names)
{
// This triggers the analyzer bug — the lambda captures `name` from the foreach loop.
tasks.AddOrchestratorFunc<string, string>(
name,
async (ctx, input) =>
{
ILogger logger = ctx.CreateReplaySafeLogger(name);
return await ctx.CallActivityAsync<string>("Activity", input);
});
}
});Note: The same code works fine when the AddOrchestratorFunc call is not inside a foreach loop.
Error Output
CSC : error AD0001: Analyzer 'Microsoft.DurableTask.Analyzers.Functions.Orchestration.CancellationTokenOrchestrationAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'node')'.
CSC : error AD0001: Analyzer 'Microsoft.DurableTask.Analyzers.Functions.Orchestration.OtherBindingsOrchestrationAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'node')'.
CSC : error AD0001: Analyzer 'Microsoft.DurableTask.Analyzers.Orchestration.DateTimeOrchestrationAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'node')'.
CSC : error AD0001: Analyzer 'Microsoft.DurableTask.Analyzers.Orchestration.DelayOrchestrationAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'node')'.
... (all orchestration analyzers crash)
Additional Context
- The analyzer is pulled transitively via
Microsoft.Azure.Functions.Worker.Extensions.DurableTaskv1.13.1 →Microsoft.DurableTask.Analyzersv0.2.0 - Adding an explicit reference to
Microsoft.DurableTask.Analyzersv0.3.0 does not fix the issue — v0.3.0 has the same bug. - Workaround: Suppress
AD0001in the project file:<NoWarn>$(NoWarn);AD0001</NoWarn>
Environment
- .NET SDK: 8.0 / 9.0 / 10.0
Microsoft.Azure.Functions.Worker.Extensions.DurableTask: 1.13.1Microsoft.DurableTask.Analyzers: 0.2.0 (also repros on 0.3.0)
Reactions are currently unavailable