ORLEANS0207: Use durable operation names without '$'
| Property | Value |
|---|---|
| Severity | Error |
| Category | Usage |
| Code fix | None |
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");}Rule description
Section titled “Rule description”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.
How to fix violations
Section titled “How to fix violations”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.
When to suppress
Section titled “When to suppress”Don’t suppress this diagnostic: the runtime rejects the name.
