Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSTHRD110: Warn for asynchronous method not awaited #233

Closed
sharwell opened this issue Apr 6, 2018 · 3 comments
Closed

VSTHRD110: Warn for asynchronous method not awaited #233

sharwell opened this issue Apr 6, 2018 · 3 comments
Assignees

Comments

@sharwell
Copy link
Member

sharwell commented Apr 6, 2018

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).

@AArnott
Copy link
Member

AArnott commented Apr 6, 2018

Similar to #209

@jstutson
Copy link

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.

@AArnott
Copy link
Member

AArnott commented May 10, 2018

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.

@AArnott AArnott self-assigned this May 10, 2018
@AArnott AArnott changed the title Warn for asynchronous method not awaited VSTHRD110: Warn for asynchronous method not awaited Jun 5, 2018
AArnott added a commit to AArnott/vs-threading that referenced this issue Jun 5, 2018
AArnott pushed a commit to AArnott/vs-threading that referenced this issue Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants