dotnet/roslyn

Misleading error for await in the watch window

Offen

#46.795 geöffnet am 13.08.2020

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-InteractiveBughelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Version Used: VS 16.7.1

Steps to Reproduce:

Attempt to use the await operator (e.g. await Task.Delay(0)) in the watch window while debugging a method.

Expected Behavior:

An error message explaining that the debugger doesn't support await, possibly suggesting to use .Result/.Wait() instead. Or even better, await works in the debugger.

Actual Behavior:

In the case of an async method, the error shown in the watch window is:

error CS4032: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<Task>'.

For a non-async method, the error is almost the same:

error CS4033: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.

In both cases, the error is misleading: For the async method, it's already async and returns a Task, so the suggestion doesn't make sense. For the non-async method, adding async wouldn't fix the issue, so it's also wrong.

Contributor Guide