Skip to content

async-suffix

C#styleno fixdefault: off

Reports an async method that returns Task or ValueTask and whose name does not end in Async. Overrides, explicit interface implementations and Main are not reported, because their names are not the method’s to choose. Renaming needs the binding layer, so there is no fix.

The suffix tells the caller that the method returns a task that has to be awaited. A call that forgets await on Load() compiles and runs on without waiting, but LoadAsync() calls for it. It also leaves room for a synchronous Load() next to it.

To fix, rename the method to end in Async.

Reported
...
interface I { Task Run(); }
class A : I {
public async Task Run() { }
public async Task Other() { }
}
class B {
class Task { }
...
csharp:
lint:
rules:
async-suffix: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line async-suffix in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
Roslynator RCS1046 full