fix: add missing lastParameter variable in TimeoutCancellationTokenAnalyzer#4956
fix: add missing lastParameter variable in TimeoutCancellationTokenAnalyzer#4956
Conversation
…alyzer PR #4924 introduced a reference to `lastParameter` without declaring it, causing CS0103 build errors. Add the variable declaration and also point the CancellationTokenMustBeLastParameter diagnostic at the actual CancellationToken parameter location.
Code ReviewNo high-signal issues found. Checked for bugs and CLAUDE.md compliance. SummaryThis is a correct and minimal fix for the regression introduced in #4924. The two changes are both good:
Minor Note (non-blocking)CLAUDE.md asks to "prefer latest syntax and APIs." Since Overall this is a well-scoped, correct fix. |
PR #4956 changed the CancellationTokenMustBeLastParameter diagnostic to point at the CancellationToken parameter instead of the method name. Update 3 test expectations to match the new diagnostic location.
* fix: update Core public API snapshots for all frameworks The merged PRs #4929 (hardcoded constants) and #4949 (retry policies) added new public API surface to TUnit.Core but the DotNet8_0, DotNet9_0, and DotNet10_0 verified snapshot files were not updated, causing Core_Library_Has_No_API_Changes test failures in all PR CI pipelines. * fix: update analyzer tests for CancellationToken parameter location PR #4956 changed the CancellationTokenMustBeLastParameter diagnostic to point at the CancellationToken parameter instead of the method name. Update 3 test expectations to match the new diagnostic location.
Summary
lastParameteron line 73 ofTimeoutCancellationTokenAnalyzer.cswithout declaring the variable, causingCS0103build errors onmainvar lastParameter = parameters[parameters.Length - 1]declaration before the usageCancellationTokenMustBeLastParameterdiagnostic at the actual CancellationToken parameter location instead of the methodTest plan
dotnet build TUnit.Analyzers/TUnit.Analyzers.csprojpasses with 0 errors