xUnit1051 ("Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken") is new in the xUnit v3 analyzer set and ships at warning severity. Because Directory.Build.props sets TreatWarningsAsErrors=true, it becomes a hard build break on several thousand call sites — every await of anything with a CancellationToken overload. A 498-line pilot project produced 12 errors on its own.
It was suppressed repo-wide in Directory.Build.props as part of the v3 migration (#3699) so the framework swap would not also be a behavioural change to how tests cancel.
This issue tracks bringing it back, so "turn it off now, bring it in later" does not become permanent by default.
Suggested approach
Re-enable per project, smallest suites first, rather than repo-wide in one go — the fix is genuinely behavioural, not cosmetic: passing TestContext.Current.CancellationToken changes what happens when a test is cancelled or times out.
<!-- in the test project, once its call sites are fixed -->
<NoWarn>$(NoWarn.Replace('xUnit1051',''))</NoWarn>
Context
See XUNIT3-MIGRATION-PLAN.md §4 for the measurement and the reasoning behind deferring it.
xUnit1051("Calls to methods which accept CancellationToken should useTestContext.Current.CancellationToken") is new in the xUnit v3 analyzer set and ships at warning severity. BecauseDirectory.Build.propssetsTreatWarningsAsErrors=true, it becomes a hard build break on several thousand call sites — everyawaitof anything with aCancellationTokenoverload. A 498-line pilot project produced 12 errors on its own.It was suppressed repo-wide in
Directory.Build.propsas part of the v3 migration (#3699) so the framework swap would not also be a behavioural change to how tests cancel.This issue tracks bringing it back, so "turn it off now, bring it in later" does not become permanent by default.
Suggested approach
Re-enable per project, smallest suites first, rather than repo-wide in one go — the fix is genuinely behavioural, not cosmetic: passing
TestContext.Current.CancellationTokenchanges what happens when a test is cancelled or times out.Context
See
XUNIT3-MIGRATION-PLAN.md§4 for the measurement and the reasoning behind deferring it.