Regression from 2.10.0 when activities use derived interfaces and generics
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 6
Description
After updating `Microsoft.Azure.DurableTask.Core` from 2.10.0 to 2.13.0, we see a regression when using derived interfaces for activities. Essentially, we have a base interface for some activities, and derive from that into more specialized interfaces.
The code below is similar to what we have and will reproduce the issue.
On 2.10.0 this works as expected, but on 2.13.0 this will timeout in `client.WaitForOrchestration`. From a breakpoint I see that the activity is never called. On 2.13.0, if I change the generic constraint on `OrchestrationImplementation` from `IRootActivities` to `IDerivedActivities`, it works on 2.13.0 as well.
```
using DurableTask.Core;
using DurableTask.Emulator;
public class DtfRepro
{
public async Task DoRepro()
{
var orchestrationService = new LocalOrchestrationService();
var worker = new TaskHubWorker(orchestrationService);
worker.AddTaskActivitiesFromInterface(new ActivityImplementation(), true);
worker.AddTaskActivities(typeof(ActivityImplementation));
worker.AddTaskOrchestrations(typeof(OrchestrationImplementation));
await worker.StartAsync();
var client = new TaskHubClient(orchestrationService);
var result = await client.CreateOrchestrationInstanceAsync(typeof(OrchestrationImplementation), Guid.NewGuid());
var state = await client.WaitForOrchestrationAsync(result, TimeSpan.FromSeconds(60));
Console.WriteLine(state.OrchestrationStatus);
}
}
public interface IRootActivities
{
Task DoWork(Guid id);
}
public interface IDerivedActivities : IRootActivities
{
// Required, otherwise client.DoWork(input) in OrchestrationImplementaion will fail with "Method name 'DoWork' not known.".
new Task DoWork(Guid id);
}
public class ActivityImplementation : IDerivedActivities
{
public Task DoWork(Guid id)
{
return Task.FromResult(true);
}
}
public class OrchestrationImplementation : TaskOrchestration
where TInterface : class, IRootActivities
{
public override async Task RunTask(OrchestrationContext context, Guid input)
{
var client = context.CreateClient(true);
var result = await client.DoWork(input);
return result;
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.