Skip to content

No mixed cancellation diagnostic on interfaceless handlers#388

Merged
DavidBoike merged 3 commits intomasterfrom
interfaceless-handlers
Mar 11, 2026
Merged

No mixed cancellation diagnostic on interfaceless handlers#388
DavidBoike merged 3 commits intomasterfrom
interfaceless-handlers

Conversation

@DavidBoike
Copy link
Member

If a method:

  1. Is named Handler/HandlerAsync/Process/ProcessAsync
  2. Its containing class does not implement IHandleMessages
  3. Its containing class is marked by the HandlerAttribute

Then diagnostic PS0014 "Methods should not have both CancellationToken parameters and parameters implementing ICancellableContext" will not be raised.

@DavidBoike DavidBoike self-assigned this Mar 10, 2026
}

if (tokens > 0 && contexts > 0)
if (tokens > 0 && contexts > 0 && !IsInterfacelessHandlerMethod(method))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the Particular analyzers around cancellation and a CancellableContext use more of a "looks like" comparison, and don't reference NServiceBus types in the tests at all, so symbol comparison wouldn't work.

@DavidBoike DavidBoike merged commit 9793f45 into master Mar 11, 2026
4 checks passed
@DavidBoike DavidBoike deleted the interfaceless-handlers branch March 11, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants