-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
File: TUnit.Analyzers/GlobalTestHooksAnalyzer.cs (Lines 150-184)
if (parameters.Length == 1 &&
parameters[0].Type.GloballyQualifiedNonGeneric() == "global::System.Threading.CancellationToken")
{
return HookParameterStatus.Valid; // Accepts without checking default value
}
The analyzer accepts CancellationToken alone as valid without checking if it has a default value. A bare CancellationToken cancellationToken parameter without a default will cause runtime issues, but the analyzer says it's valid.
Impact
Users get runtime errors instead of compile-time diagnostics.
Suggested Fix
if (parameters.Length == 1 &&
parameters[0].Type.GloballyQualifiedNonGeneric() == "global::System.Threading.CancellationToken" &&
parameters[0].HasExplicitDefaultValue) // ← Add this check
{
return HookParameterStatus.Valid;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working