c# – The auto-completion for await changes the method’s signature – how do I prevent that?


I cannot reproduce the problem.

before tab

enter image description here

afer tab

enter image description here

I’m running

Microsoft Visual Studio Professional 2022
Version 17.11.5

C# Tools   4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

In a response to a related issue async/await Visual Studio autocomplete #68512 on github the functionality is mentioned:

We also just add ‘async’ automatically to the method if you try to complete out await in your method body.

It does not mention any modification of the return type (or lack thereof). Note that the opener of the issue explicitly asks for a modification of the return type to Task, which is the undesired behavior that you observe.
However the issue is “closed as not planned”.

In this PR, the functionality was implemented including the modification of the return type.

Leave a Reply

Your email address will not be published. Required fields are marked *