Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

79 lines
1.7 KiB
Plaintext

== Why is this an issue?
According to the Task-based Asynchronous Pattern (TAP), methods returning either a ``++System.Threading.Tasks.Task++`` or a ``++System.Threading.Tasks.Task<TResult>++`` are considered "asynchronous". Such methods should use the ``++Async++`` suffix. Conversely methods which do not return such Tasks should not have an "Async" suffix in their names.
=== Noncompliant code example
[source,csharp]
----
using System;
using System.Threading.Tasks;
namespace myLibrary
{
public class Foo
{
public Task Read(byte [] buffer, int offset, int count, // Noncompliant
CancellationToken cancellationToken)
}
}
----
=== Compliant solution
[source,csharp]
----
using System;
using System.Threading.Tasks;
namespace myLibrary
{
public class Foo
{
public Task ReadAsync(byte [] buffer, int offset, int count, CancellationToken cancellationToken)
}
}
----
=== Exceptions
This rule doesn't raise an issue when the method is an override or part of the implementation of an interface since it can not be renamed.
== Resources
* https://docs.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap[Task-based Asynchronous Pattern]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add an "Async" suffix to the name of this method.
Remove the "Async" suffix from the name of this method.
=== Highlighting
Method name in declaration
'''
== Comments And Links
(visible only on this page)
=== on 10 Aug 2018, 16:07:12 Amaury Levé wrote:
Reduce the default severity to code smell as the worst case scenario is confusion for the end-user.
endif::env-github,rspecator-view[]