Skip to content

Commit

Permalink
Add initial documentation for IncludeCancellationParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Aug 6, 2018
1 parent 68e64c0 commit 6ac3fe9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions AsyncUsageAnalyzers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat
ProjectSection(SolutionItems) = preProject
documentation\AvoidAsyncSuffix.md = documentation\AvoidAsyncSuffix.md
documentation\AvoidAsyncVoid.md = documentation\AvoidAsyncVoid.md
documentation\IncludeCancellationParameter.md = documentation\IncludeCancellationParameter.md
documentation\UseAsyncSuffix.md = documentation\UseAsyncSuffix.md
documentation\UseConfigureAwait.md = documentation\UseConfigureAwait.md
EndProjectSection
Expand Down
43 changes: 43 additions & 0 deletions documentation/IncludeCancellationParameter.md
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);
}
```

0 comments on commit 6ac3fe9

Please sign in to comment.