-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Labels
Area-CompilersConcept-Diagnostic ClarityThe issues deals with the ease of understanding of errors and warnings.The issues deals with the ease of understanding of errors and warnings.Feature - Runtime Async
Milestone
Description
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
pawchenCopilot
Metadata
Metadata
Labels
Area-CompilersConcept-Diagnostic ClarityThe issues deals with the ease of understanding of errors and warnings.The issues deals with the ease of understanding of errors and warnings.Feature - Runtime Async