Skip to content

[Feature Request] Nexus: allow [TemporalOperation] handler methods to keep the "Async" suffix #878

Description

@jmaeagle99

Is your feature request related to a problem? Please describe.

Handler methods are matched to the service definition by exact method name, so a [TemporalOperation] method has to be named Greet, not GreetAsync. But it returns Task<TemporalOperationResult<T>>, so VSTHRD200 wants the suffix, and adding it fails at AddNexusService:

ArgumentException: Missing handlers for defined operations: 'Greet'

Renaming the interface method to match doesn't help: definition methods can't return Task, so VSTHRD200 then complains in the other direction about a non-awaitable method ending in Async.

The result is that every [TemporalOperation] method needs a #pragma warning disable VSTHRD200 (see samples-dotnet#214). This is specific to [TemporalOperation]. [NexusOperationHandler] factory style returns IOperationHandler<,>, so the analyzer never fires there.

Describe the solution you'd like

Trim a trailing Async when matching a handler method to an operation, the way [Activity], [WorkflowSignal], and [WorkflowUpdate] already do when deriving their default names. The wire operation name would keep coming from the definition, so nothing cross-language changes.

Additional context

Temporalio 1.18.0, NexusRpc 0.4.0.

The matching happens in NexusRpc's ServiceHandlerInstance.FromInstance (o.MethodInfo?.Name == method.Name), so the change may belong in nexus-rpc/sdk-dotnet instead. Filing here because [TemporalOperation] is where it's actually hit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions