Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 789 Bytes

PH_P007.md

File metadata and controls

17 lines (11 loc) · 789 Bytes

PH_P007 - Unused Cancellation Token

Problem

One of the enclosing scopes holds a cancellation token. However, an invoked method does not receive this token although it or one of its overloads accept a cancellation token. Cancellation tokens are meaningless if not used accordingly.

Solution

Pass the cancellation token of the enclosing scope to the invoked method. If the invoked method must not be canceled (e.g., for logging a failure), pass CancellationToken.None instead to explicitly state the intention.

Options

# A white-space separated list of methods to exclude when searching for method invocations that miss the cancellation token
# Format: <type-specifier>:<method1>,<method2>
dotnet_diagnostic.PH_P007.exclusions = System.Threading.Tasks.Task:Run