Azure / Azure/durabletask

CreateClient/AddTaskActivitiesFromInterface with non-Task methods

Aperta
#592 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
1.7k
Fork
335
Merge medio
2g 23h
PR unite (30g)
6

Descrizione

Consider the following interface and implementation:

public interface IClient
{
    IEnumerable<string> GetUsers();
}

public class Client : IClient
{
    public IEnumerable<string> GetUsers()
    {
        return new[] { "user1", "user2" };
    }
}

When using AddTaskActivitiesFromInterface like so:

taskHub.AddTaskActivitiesFromInterface<IClient>(new Client());

and then creating a client within an orchestration:

var client = context.CreateClient<IClient>();
var users = client.GetUsers();
foreach (var user in users)
{
    string greeting = await context.ScheduleTask<string>(typeof(SendGreetingTask), user);
}

This will result in an error since the returned value is not an IEnumerable<string>. It appears that the actual result is System.Threading.Tasks.Task1[System.String]` with an underlying "ActLike_IEnumerable" type.

From the looks of it, the root cause is coming from ScheduleProxy.TryInvokeMember, which assumes that the returned type is of type Task<T>, but "swallows" a IEnumerable<T> in the same way.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da ScheduleProxy.TryInvokeMember e riproduci l’esempio IClient usando AddTaskActivitiesFromInterface e CreateClient. Traccia come viene classificato il tipo restituito per i metodi che non sono di tipo Task rispetto ai metodi di tipo Task. Il lavoro è completo quando GetUsers restituisce correttamente IEnumerable, mentre i metodi di attività basati su Task continuano a funzionare, con copertura di regressione se viene individuata la posizione esistente dei test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
backend, distributed-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.