Using Microsoft.DurableTask.Generators 2.1.0-preview.1, I'm creating the following activity function:
[DurableTask]
public class WorkerCapacityReviewActivity(IWorkerPoolRepository repository) : TaskActivity<object?, WorkerCapacityReviewResult>
{
public override async Task<WorkerCapacityReviewResult> RunAsync(TaskActivityContext context, object? input)
{
// some irrelevant work here
}
}
Since this is just a check for the current capacity of the system this activity doesn't require an input, so I'm using object?. The problem comes when the generator runs on this:
[Function(nameof(WorkerCapacityReviewActivity))]
public static async Task<WorkerCapacityReviewResult> WorkerCapacityReviewActivity([ActivityTrigger] object? input = default, string instanceId, FunctionContext executionContext)
{
ITaskActivity activity = ActivatorUtilities.GetServiceOrCreateInstance<WorkerCapacityReviewActivity>(executionContext.InstanceServices);
TaskActivityContext context = new GeneratedActivityContext("WorkerCapacityReviewActivity", instanceId);
object? result = await activity.RunAsync(context, input);
return (WorkerCapacityReviewResult)result!;
}
As you can see, it is adding = default to the input, but this is not valid given there are subsequent arguments that dont also have default values. As a workaround I believe I need to make it pass through an unused value, which should work but is certainly not ideal.
Using
Microsoft.DurableTask.Generators 2.1.0-preview.1, I'm creating the following activity function:Since this is just a check for the current capacity of the system this activity doesn't require an input, so I'm using
object?. The problem comes when the generator runs on this:As you can see, it is adding
= defaultto the input, but this is not valid given there are subsequent arguments that dont also have default values. As a workaround I believe I need to make it pass through an unused value, which should work but is certainly not ideal.