Add NexusOperationHandler annotation - #764
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f76d3e21a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
jmaeagle99
left a comment
There was a problem hiding this comment.
Small amount of feedback, but looks good overall. Will approve when dependency has been updated.
Side note: this is ripe for source generation, which would create compile-time safe operation registration, but still use the reflection and expression compilation as a fallback. I'm going to log an issue to track this, as there are other areas that can benefit as well.
|
Please update CHANGELOG.md with a blurb in the Added section. |
f347b9a to
24200f6
Compare
jmaeagle99
left a comment
There was a problem hiding this comment.
I think the one pitfall of this design is that if a method is attributed with [TemporalOperation] but it's name doesn't match a method in the service interface, then it is silently ignored. This might lead to typo-created mismatches given that the service implementation doesn't implemented the service interface. Not sure what to do with that without given the entire service definition to Temporalio to validate all attributed methods at once. Maybe could be done better with an analyzer.
24200f6 to
34d51f1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 34d51f1. Configure here.
Consume the published NexusRpc 0.4.0 test package and configure its integration feed so clean environments can restore the PR without a local Nexus SDK repository. Constraint: NexusRpc 0.4.0 is currently published on the NuGet integration server, not nuget.org. Confidence: high Scope-risk: narrow Tested: dotnet restore --locked-mode; dotnet format --verify-no-changes --no-restore; 85 targeted Nexus tests (82 passed, 3 skipped) Not-tested: full test suite

What was changed
Add
NexusOperationHandlerannotation that can be used in Nexus Service Handlers on Temporal WorkersWhy?
Makes it easier to declare Nexus Service Handlers with less boilerplate
Checklist
Closes
How was this tested:
Note to reviewers:
nexus-rpc/sdk-dotnet#19 needs to land first and most of the package lock changes are only here to test locally
Note
Medium Risk
Touches experimental Nexus registration, hosting DI lifetimes, and bumps NexusRpc to 0.4.0; behavior changes are localized but affect worker startup and operation dispatch paths.
Overview
Introduces
[TemporalOperation]so a method on a[NexusServiceHandler]class can be the Nexus operation start handler directly (returningTask<TemporalOperationResult<T>>withTemporalOperationStartContextandITemporalNexusClient), instead of wiring a[NexusOperationHandler]factory aroundTemporalOperationHandler.FromHandleFactory. Operations are still matched by method name to the service interface; the attribute cannot be combined with[NexusOperationHandler]on the same method.TemporalOperationMethodExtensionplugs into NexusRpcIMethodExtension(requires NexusRpc 0.4.0). Worker, simple-plugin, and hosting registration now pass this extension intoServiceHandlerInstance.FromInstance. HostingServiceHandlerInstanceHelperandScopedOperationHandlerwere reworked so both attribute styles resolve handlers per operation, with a fresh DI scope and service instance on each start/cancel for[TemporalOperation](aligned with activities). Unmatched[NexusOperationHandler]methods fail registration like NexusRpc’s built-in path.Adds
NuGet.Configpackage-source mapping for the NexusRpc test feed (local testing). Changelog and broad test coverage for validation, execution, DI lifetimes, and mixed handlers.Reviewed by Cursor Bugbot for commit 8483d93. Bugbot is set up for automated code reviews on this repo. Configure here.