Skip to content

Generated code produces warnings CS0419 and VSTHRD105 breaking builds with TreatWarningsAsErrors #624

@leandrodeopereira

Description

@leandrodeopereira

Description:

Summary

The DurableTaskSourceGenerator generates code in GeneratedDurableTaskExtensions.cs that produces compiler warnings CS0419 and VSTHRD105, which breaks builds when TreatWarningsAsErrors is enabled.

Environment

  • Package: Microsoft.DurableTask.Generators v1.0.0-preview.1
  • Target Framework: net10.0
  • Azure Functions: v4
  • Project Configuration: <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
  • Analyzers:
    • Microsoft.Extensions.StaticAnalysis v10.2.0
    • Standard Roslyn analyzers (C# compiler)

Reproduction

Full reproducible example available at: https://github.com/leandrodeopereira/azure-function-test

The project uses standard [DurableTask] attributes on orchestrators and activities , which triggers the source generator. Support class-based durable function invocations

Generated Code Issues

1. VSTHRD105 - Missing TaskScheduler parameter

// Generated in GeneratedDurableTaskExtensions.cs
return singletonSayHelloOrchestrator.RunAsync(context, context.GetInput<string>())
    .ContinueWith(t => (List<string>)(t.Result ?? default(List<string>)!), 
                  TaskContinuationOptions.ExecuteSynchronously);
    // ❌ Missing TaskScheduler parameter - assumes TaskScheduler.Current

Error:

VSTHRD105: Avoid method overloads that assume TaskScheduler.Current. 
Use an overload that accepts a TaskScheduler and specify TaskScheduler.Default explicitly.
https://microsoft.github.io/vs-threading/analyzers/VSTHRD105.html

2. CS0419 - Ambiguous cref in XML documentation

/// <inheritdoc cref="TaskOrchestrationContext.CallSubOrchestratorAsync"/>
public static Task<List<string>> CallSayHelloOrchestratorAsync(...)
// ❌ Ambiguous - multiple overloads match

Error:

CS0419: Ambiguous reference in cref attribute: 'TaskOrchestrationContext.CallSubOrchestratorAsync'. 
Assuming 'TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, TaskOptions)', 
but could have also matched other overloads.

Impact

Blocks usage of the generator in projects with TreatWarningsAsErrors enabled (standard for production code).

Current workarounds all compromise code quality:

  • <NoWarn>CS0419;VSTHRD105</NoWarn> - Disables warnings

Expected Behavior

Generated code should compile cleanly with strict compiler settings and standard analyzers.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions