Skip to content

Drop redundant cancellation token arguments from the test projects - #5769

Merged
johnsimons merged 1 commit into
masterfrom
john/cancel_p7_test_projects
Aug 13, 2026
Merged

johnsimons merged 1 commit into
masterfrom
john/cancel_p7_test_projects

Conversation

@johnsimons

Copy link
Copy Markdown
Member

Retires the PS0003, PS0006, PS0008, PS0017 and PS0019 debt across the test projects, and corrects the justification on what is left. Phase 7 of the propagation work. Stacked on the persistence and licensing change, whose optional parameters this depends on.

Because the production tokens are now optional, 139 call sites that passed the default literal do not need CancellationToken.None in its place: they drop the argument entirely and read as ordinary calls. Tests that genuinely exercise cancellation keep using [Test, CancelAfter(...)] with the token NUnit injects.

Test methods that take that injected token gain "= default", which is what PS0003 asks for on a non-private member and does not affect NUnit's injection.

The remaining PS0018 and PS0013 blocks are reworded. The previous text claimed these were accepted exceptions because the rule would demand a token on every [Test] method. That is not what happens: Particular.Analyzers already exempts NUnit test methods, and measuring it showed 301 of the 306 sites are ordinary helper methods. The blocks now say what is actually left, which is threading tokens through the helper chain and the callback shapes the NServiceBus scenario API fixes, so it reads as scheduled work rather than a settled decision.

Two shared container helpers rename ct to cancellationToken and rethrow their own cancellation before mapping container start failures. WatchdogTests does the same around its expected-exception assertion.

Retires the PS0003, PS0006, PS0008, PS0017 and PS0019 debt across the test
projects, and corrects the justification on what is left. Phase 7 of the
propagation work. Stacked on the persistence and licensing change, whose
optional parameters this depends on.

Because the production tokens are now optional, 139 call sites that passed
the default literal do not need CancellationToken.None in its place: they
drop the argument entirely and read as ordinary calls. Tests that genuinely
exercise cancellation keep using [Test, CancelAfter(...)] with the token
NUnit injects.

Test methods that take that injected token gain "= default", which is what
PS0003 asks for on a non-private member and does not affect NUnit's
injection.

The remaining PS0018 and PS0013 blocks are reworded. The previous text
claimed these were accepted exceptions because the rule would demand a
token on every [Test] method. That is not what happens: Particular.Analyzers
already exempts NUnit test methods, and measuring it showed 301 of the 306
sites are ordinary helper methods. The blocks now say what is actually
left, which is threading tokens through the helper chain and the callback
shapes the NServiceBus scenario API fixes, so it reads as scheduled work
rather than a settled decision.

Two shared container helpers rename ct to cancellationToken and rethrow
their own cancellation before mapping container start failures.
WatchdogTests does the same around its expected-exception assertion.
@johnsimons
johnsimons requested a review from rbev August 13, 2026 06:58
@johnsimons johnsimons self-assigned this Aug 13, 2026
@johnsimons
johnsimons merged commit e993fe3 into master Aug 13, 2026
54 checks passed
@johnsimons
johnsimons deleted the john/cancel_p7_test_projects branch August 13, 2026 08:25
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