Repository navigation
Description
Expected Behavior
The Dapr workflow versioning source generator should ignore abstract or open generic workflow base classes, or otherwise avoid emitting registration/versioning entries for them.
For a concrete workflow that inherits through a generic workflow base class, the generator should only register the concrete closed workflow type:
internal abstract class VersionedWorkflow<TInput, TOutput> : Workflow<TInput, TOutput>
{
}
internal sealed partial class OrderProcessingWorkflow
: VersionedWorkflow<OrderPayload, OrderResult>
{
public override Task<OrderResult> RunAsync(WorkflowContext context, OrderPayload order)
{
// workflow implementation
}
}The generated code should compile and should not emit references to the open generic base type.
Actual Behavior
The workflow versioning source generator discovers the abstract open generic base class as a workflow and emits it into the generated registry.
This produces invalid generated code containing unresolved generic type parameters:
options.RegisterWorkflow<global::DaprWorkflowExploration.ApiService.Workflows.VersionedWorkflow<TInput, TOutput>>(...);
new Entry(
typeof(global::DaprWorkflowExploration.ApiService.Workflows.VersionedWorkflow<TInput, TOutput>),
...);The build then fails with CS0246 because TInput and TOutput are not in scope in the generated registry file.
Representative errors:
Dapr_Workflow_Versioning.g.cs(24,263): error CS0246: The type or namespace name 'TInput' could not be found
Dapr_Workflow_Versioning.g.cs(24,271): error CS0246: The type or namespace name 'TOutput' could not be found
Dapr_Workflow_Versioning.g.cs(87,109): error CS0246: The type or namespace name 'TInput' could not be found
Dapr_Workflow_Versioning.g.cs(87,117): error CS0246: The type or namespace name 'TOutput' could not be found
Steps to Reproduce the Problem
- Add a workflow that derives directly from
Workflow<TInput, TOutput>and confirm it builds:
internal sealed partial class OrderProcessingWorkflow : Workflow<OrderPayload, OrderResult>
{
public override Task<OrderResult> RunAsync(WorkflowContext context, OrderPayload order)
{
return Task.FromResult(new OrderResult());
}
}- Change only the inheritance to use an abstract generic base class:
internal abstract class VersionedWorkflow<TInput, TOutput> : Workflow<TInput, TOutput>
{
}
internal sealed partial class OrderProcessingWorkflow
: VersionedWorkflow<OrderPayload, OrderResult>
{
public override Task<OrderResult> RunAsync(WorkflowContext context, OrderPayload order)
{
return Task.FromResult(new OrderResult());
}
}- Build the project.
The build fails in the generated file:
Dapr.Workflow.Versioning.Generators/Dapr.Workflow.Versioning.WorkflowSourceGenerator/Dapr_Workflow_Versioning.g.cs
The likely root cause is that BuildDiscoveredWorkflow marks abstract and open generic workflow types with IsAbstractOrGeneric, and the simple auto-registration path uses that flag to exclude them. The versioning registration path does not apply the same filter, so it still generates registration and registry entries for every discovered workflow, including abstract/open generic base classes.
Release Note
RELEASE NOTE: FIX Workflow versioning source generator ignores abstract/open generic workflow base classes.
Activity