Skip to content

Consider not emitting CS1998 for interface implementations / method overrides #77001

@stephentoub

Description

@stephentoub

CS1998 warns about async methods that lack any awaits. There's a balance to be struck here, as there are valid scenarios for this to happen, especially when you're forced to have a Task-returning method due to external requirements, e.g. you're overriding a Task-returning method or you're implementing an interface method. I end up seeing a non-trivial amount of code that gets this warning in such cases, and then rather than suppressing it, they add in an unnecessary await, e.g. await Task.FromResult(result), which doesn't make the method any "safer" but does make it more expensive.

I suggest we consider not emitting CS1998 when the async method in question is an override or is part of implementing an interface.

cc: @jcouv

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions