Skip to content

VSTHRD110: Warn for asynchronous method not awaited #233

Closed

Description

@sharwell

Compiler warning CS4014 is only reported if the callee is marked with the async modifier (dotnet/roslyn#20782). It would be helpful if an analyzer expanded the analysis to cover cases where the method does not have this modifier (e.g. pass-through asynchronous methods).

Activity

  1. AArnott commented on Apr 6, 2018

    @AArnott
    Member

    Similar to #209

  2. jstutson commented on May 10, 2018

    @jstutson

    This is needed so so very much especially for solutions undergoing a conversion to async patterns. Very often you will change a method to return Task with no intention of it ever being fire-and-forget. You must then very carefully find all usages of the method up the chain and ensure that all callers await the call. Those callers then become async and so on and so on. Without an analyzer for this, the effort is extremely error prone and errors manifest during runtime in a manner which is very difficult to diagnose.

    At my prior company, we had analyzers which enforced that fire-and-forget method invocation be explicitly marked by an extension I.E "task.NoWait()". Otherwise, you get an error.

    With concerns of backwards compatibility I can see the difficulty in .Net including the analyzer by default... But there must be some way to toggle it on/off for those who need it. This is very common use-case.

  3. AArnott commented on May 10, 2018

    @AArnott
    Member

    Your NoWait() extension method sounds analogous to the Forget() extension method that we define within this project.

    I should be able to get to this feature request in the next week.

  4. changed the title [-]Warn for asynchronous method not awaited[/-] [+]VSTHRD110: Warn for asynchronous method not awaited[/+] on Jun 5, 2018
  5. added a commit that references this issue on Jun 5, 2018
    6d39c3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions