Skip to content

Commit b2ed777

Browse files
committed
Updated documentation and links
1 parent 953d051 commit b2ed777

File tree

9 files changed

+169
-4
lines changed

9 files changed

+169
-4
lines changed

AsyncUsageAnalyzers.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{11D3EB88
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncUsageAnalyzers.CodeFixes", "AsyncUsageAnalyzers\AsyncUsageAnalyzers.CodeFixes\AsyncUsageAnalyzers.CodeFixes.csproj", "{BA0CD420-1E79-4FBC-B023-09C03BCDFFAC}"
3030
EndProject
31+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentation", "{9E388950-B857-4C92-9429-676FE26BF115}"
32+
ProjectSection(SolutionItems) = preProject
33+
documentation\AvoidAsyncSuffix.md = documentation\AvoidAsyncSuffix.md
34+
documentation\AvoidAsyncVoid.md = documentation\AvoidAsyncVoid.md
35+
documentation\UseAsyncSuffix.md = documentation\UseAsyncSuffix.md
36+
documentation\UseConfigureAwait.md = documentation\UseConfigureAwait.md
37+
EndProjectSection
38+
EndProject
3139
Global
3240
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3341
Debug|Any CPU = Debug|Any CPU

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/AvoidAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class AvoidAsyncSuffixAnalyzer : DiagnosticAnalyzer
2222
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.AvoidAsyncSuffixMessageFormat), NamingResources.ResourceManager, typeof(NamingResources));
2323
private static readonly string Category = "AsyncUsage.CSharp.Naming";
2424
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.AvoidAsyncSuffixDescription), NamingResources.ResourceManager, typeof(NamingResources));
25-
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers";
25+
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers/blob/master/documentation/AvoidAsyncSuffix.md";
2626

2727
private static readonly DiagnosticDescriptor Descriptor =
2828
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Naming/UseAsyncSuffixAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class UseAsyncSuffixAnalyzer : DiagnosticAnalyzer
2222
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.UseAsyncSuffixMessageFormat), NamingResources.ResourceManager, typeof(NamingResources));
2323
private static readonly string Category = "AsyncUsage.CSharp.Naming";
2424
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.UseAsyncSuffixDescription), NamingResources.ResourceManager, typeof(NamingResources));
25-
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers";
25+
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers/blob/master/documentation/UseAsyncSuffix.md";
2626

2727
private static readonly DiagnosticDescriptor Descriptor =
2828
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Reliability/AvoidAsyncVoidAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class AvoidAsyncVoidAnalyzer : DiagnosticAnalyzer
2424
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReliabilityResources.AvoidAsyncVoidMessageFormat), ReliabilityResources.ResourceManager, typeof(ReliabilityResources));
2525
private static readonly string Category = "AsyncUsage.CSharp.Reliability";
2626
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReliabilityResources.AvoidAsyncVoidDescription), ReliabilityResources.ResourceManager, typeof(ReliabilityResources));
27-
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers";
27+
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers/blob/master/documentation/AvoidAsyncVoid.md";
2828

2929
private static readonly DiagnosticDescriptor Descriptor =
3030
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);

AsyncUsageAnalyzers/AsyncUsageAnalyzers/Usage/UseConfigureAwaitAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class UseConfigureAwaitAnalyzer : DiagnosticAnalyzer
2424
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(UsageResources.UseConfigureAwaitMessageFormat), UsageResources.ResourceManager, typeof(UsageResources));
2525
private static readonly string Category = "AsyncUsage.CSharp.Usage";
2626
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(UsageResources.UseConfigureAwaitDescription), UsageResources.ResourceManager, typeof(UsageResources));
27-
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers";
27+
private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers/blob/master/documentation/UseConfigureAwait.md";
2828

2929
private static readonly DiagnosticDescriptor Descriptor =
3030
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Hidden, AnalyzerConstants.EnabledByDefault, Description, HelpLink);

documentation/AvoidAsyncSuffix.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## AvoidAsyncSuffix
2+
3+
<table>
4+
<tr>
5+
<td>TypeName</td>
6+
<td>AvoidAsyncSuffix</td>
7+
</tr>
8+
<tr>
9+
<td>CheckId</td>
10+
<td>AvoidAsyncSuffix</td>
11+
</tr>
12+
<tr>
13+
<td>Category</td>
14+
<td>Naming Rules</td>
15+
</tr>
16+
</table>
17+
18+
## Cause
19+
20+
A non-Task-returning method is named with the suffix `Async`.
21+
22+
## Rule description
23+
24+
This diagnostic identifies methods which are not asynchronous according to the Task-based Asynchronous Pattern (TAP) by
25+
their signature, and reports a warning if the method name includes the suffix `Async`.
26+
27+
## How to fix violations
28+
29+
To fix a violation of this rule, remove the `Async` suffix from the method name or change the signature to return a
30+
`Task`.
31+
32+
## How to suppress violations
33+
34+
```csharp
35+
#pragma warning disable AvoidAsyncSuffix // Avoid Async suffix
36+
public int ThisIsNotAsync()
37+
#pragma warning restore AvoidAsyncSuffix // Avoid Async suffix
38+
{
39+
return 0;
40+
}
41+
```

documentation/AvoidAsyncVoid.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## AvoidAsyncVoid
2+
3+
<table>
4+
<tr>
5+
<td>TypeName</td>
6+
<td>AvoidAsyncVoid</td>
7+
</tr>
8+
<tr>
9+
<td>CheckId</td>
10+
<td>AvoidAsyncVoid</td>
11+
</tr>
12+
<tr>
13+
<td>Category</td>
14+
<td>Reliability Rules</td>
15+
</tr>
16+
</table>
17+
18+
## Cause
19+
20+
An asynchronous method has the return type `void`.
21+
22+
## Rule description
23+
24+
This diagnostic identifies code using `void`-returning `async` methods, and reports a warning.
25+
26+
## How to fix violations
27+
28+
To fix a violation of this rule, change the signature of the method to return a `Task` instead of `void`.
29+
30+
## How to suppress violations
31+
32+
```csharp
33+
#pragma warning disable AvoidAsyncVoid // Avoid async void
34+
private async void HandleSomeEvent(object sender, EventArgs e)
35+
#pragma warning restore AvoidAsyncVoid // Avoid async void
36+
{
37+
}
38+
```

documentation/UseAsyncSuffix.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## UseAsyncSuffix
2+
3+
<table>
4+
<tr>
5+
<td>TypeName</td>
6+
<td>UseAsyncSuffix</td>
7+
</tr>
8+
<tr>
9+
<td>CheckId</td>
10+
<td>UseAsyncSuffix</td>
11+
</tr>
12+
<tr>
13+
<td>Category</td>
14+
<td>Naming Rules</td>
15+
</tr>
16+
</table>
17+
18+
## Cause
19+
20+
A Task-returning method is named without the suffix `Async`.
21+
22+
## Rule description
23+
24+
This diagnostic identifies methods which are asynchronous according to the Task-based Asynchronous Pattern (TAP) by
25+
their signature, and reports a warning if the method name does not include the suffix `Async`.
26+
27+
## How to fix violations
28+
29+
To fix a violation of this rule, rename the method to include the `Async` suffix.
30+
31+
## How to suppress violations
32+
33+
```csharp
34+
#pragma warning disable UseAsyncSuffix // Use Async suffix
35+
public async Task<int> GetValue()
36+
#pragma warning restore UseAsyncSuffix // Use Async suffix
37+
{
38+
return 0;
39+
}
40+
```

documentation/UseConfigureAwait.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## UseConfigureAwait
2+
3+
<table>
4+
<tr>
5+
<td>TypeName</td>
6+
<td>UseConfigureAwait</td>
7+
</tr>
8+
<tr>
9+
<td>CheckId</td>
10+
<td>UseConfigureAwait</td>
11+
</tr>
12+
<tr>
13+
<td>Category</td>
14+
<td>Usage Rules</td>
15+
</tr>
16+
</table>
17+
18+
## Cause
19+
20+
A `Task` whose continuation behavior has not been configured is awaited.
21+
22+
## Rule description
23+
24+
The continuation behavior for a `Task` should be configured by calling `ConfigureAwait` prior to awaiting the task. This
25+
diagnostic is reported if an `await` expression is used on a `Task` that has not been configured.
26+
27+
## How to fix violations
28+
29+
To fix a violation of this rule, use `ConfigureAwait(false)` or `ConfigureAwait(true)` as appropriate for the context of
30+
the asynchronous operation.
31+
32+
## How to suppress violations
33+
34+
```csharp
35+
#pragma warning disable UseConfigureAwait // Use ConfigureAwait
36+
await Task.Delay(1000);
37+
#pragma warning restore UseConfigureAwait // Use ConfigureAwait
38+
```

0 commit comments

Comments
 (0)