forked from DotNetAnalyzers/AsyncUsageAnalyzers
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial documentation for IncludeCancellationParameter
Fixes DotNetAnalyzers#44
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## IncludeCancellationParameter | ||
|
||
<table> | ||
<tr> | ||
<td>TypeName</td> | ||
<td>IncludeCancellationParameterAnalyzer</td> | ||
</tr> | ||
<tr> | ||
<td>CheckId</td> | ||
<td>IncludeCancellationParameter</td> | ||
</tr> | ||
<tr> | ||
<td>Category</td> | ||
<td>Usage Rules</td> | ||
</tr> | ||
</table> | ||
|
||
## Cause | ||
|
||
An asynchronous method does not include a `CancellationToken` parameter. | ||
|
||
## Rule description | ||
|
||
This diagnostic identifies asynchronous methods which do not include a `CancellationToken` parameter in their signature. | ||
|
||
## How to fix violations | ||
|
||
To fix a violation of this rule, add a `CancellationToken` parameter to the signature of the method. | ||
|
||
## How to suppress violations | ||
|
||
```csharp | ||
[SuppressMessage("AsyncUsage.CSharp.Usage", "IncludeCancellationParameter", Justification = "Reviewed.")] | ||
``` | ||
|
||
```csharp | ||
#pragma warning disable IncludeCancellationParameter // Include CancellationToken parameter | ||
public Task<int> ThisMethodCannotBeCancelled() | ||
#pragma warning restore IncludeCancellationParameter // Include CancellationToken parameter | ||
{ | ||
return Task.FromResult(0); | ||
} | ||
``` |