-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support "Make Async" on methods #7769
Comments
Adding `async' and changing the return type to Task in a single step sounds like a useful feature.
This sounds really dangerous, being that properly using async requires propagating it up the call stack. It seems pretty likely a tool doing that recursively would have unintended side effects on the program execution. |
However, without changing the methods all the way up the transformation may end up with non-compiling code. Adding |
In addition to what @i3arnon said, if the originally synchronous method calls any async methods it's likely doing some combination of |
I think this is preferable. You want to force the user (via errors) to consider the implications of making each and every method async, not just do work that may compile but is likely to have runtime bugs. |
Note that if you await a method that is not Few things we could do to improve:
|
I wrote something that does almost exactly what this issue describes: http://github.com/roji/AsyncRewriter. It's used in Npgsql (the .NET driver for PostgreSQL) to selectively generated async methods from sync counterparts. FWIW I really don't think this kind of thing belongs in the compiler. |
As @jmarolf described, the MakeAsync fix is offered as soon as you use
I think we could close this issue. Alternatively, clarify what functionality is left missing. |
+1 to this feature. It's a minor annoyance that when you create a new Razor Page or Controller from the default scaffolder in VS and have to convert the methods to async. Especially in Core where it's encouraged to async all the things. I get I could just wait until I await the method, but my brain struggles not to fix something immediately when I see it's wrong. 😄 |
Agreed. I think a core case here has been addressed. If there are more, we should call them out specifically with new issues that we can evaluate. |
It's always a huge bummer to convert a bunch of my methods to async. Right now, I have to manually add "async" to my signature, change my return type to Task, and await my method call, etc. etc.
I would love if I could just
Ctrl+.
on a method and click "Make Async" and it would do all these tedious changes for me for each method. It would also be cool if you could pipe async through all affected code...not sure how plausible that is though.The text was updated successfully, but these errors were encountered: