Description
File: TUnit.Analyzers/TimeoutCancellationTokenAnalyzer.cs (Lines 43-63)
The analyzer only checks if the last parameter is a CancellationToken. It doesn't validate:
- That
CancellationToken is the only parameter after the context parameter
- That if there's a
TestContext parameter, CancellationToken comes after it
- Methods with multiple parameters where
CancellationToken isn't last
Impact
False negatives — methods with wrong parameter order (e.g., Method(CancellationToken ct, TestContext ctx)) won't be detected.
Suggested Fix
Validate parameter order more thoroughly:
Valid: (TimeoutContext ctx, CancellationToken ct)
Valid: (CancellationToken ct)
Invalid: (TestContext ctx) - missing CancellationToken
Invalid: (CancellationToken ct, TestContext ctx) - wrong order
Description
File:
TUnit.Analyzers/TimeoutCancellationTokenAnalyzer.cs(Lines 43-63)The analyzer only checks if the last parameter is a
CancellationToken. It doesn't validate:CancellationTokenis the only parameter after the context parameterTestContextparameter,CancellationTokencomes after itCancellationTokenisn't lastImpact
False negatives — methods with wrong parameter order (e.g.,
Method(CancellationToken ct, TestContext ctx)) won't be detected.Suggested Fix
Validate parameter order more thoroughly: