Skip to content

ORLEANS0207: Use durable operation names without '$'

PropertyValue
SeverityError
CategoryUsage
Code fixNone

A constant name which WithId or DurableTask.RunInline receives inside a durable task body contains $. Outside durable task bodies, such as in clients and ordinary grain methods, WithId names a root task, which can contain $, so the rule checks only DurableTask.RunInline names there:

public async DurableTask<Charge> ChargeAsync(decimal amount)
{
var key = $"{this.GetGrainId()}/{DurableTask.Current.Id}/{DurableTask.Current.Incarnation:N}/charge";
return await DurableTask.Run(ct => payments.ChargeAsync(key, amount, ct)).WithId("charge$1");
}

The runtime generates identifiers which contain $: unnamed children and effects, such as $child-1; repeated names, such as charge$2; and runtime records, such as $signal:approved. A name with $ could equal one of them, so WithId and DurableTask.RunInline reject it inside a durable execution with ArgumentException, and the task fails when it reaches the operation.

Choose a name without $, such as one which separates its parts with -:

public async DurableTask<Charge> ChargeOnceAsync(decimal amount)
{
var key = $"{this.GetGrainId()}/{DurableTask.Current.Id}/{DurableTask.Current.Incarnation:N}/charge";
return await DurableTask.Run(ct => payments.ChargeAsync(key, amount, ct)).WithId("charge-1");
}

Name a call site once, even when one run repeats it. The runtime numbers repeated occurrences itself, so a loop which awaits .WithId("charge") creates charge, charge$2, and so on.

Don’t suppress this diagnostic: the runtime rejects the name.