Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Add initial documentation for IncludeCancellationParameter #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
```