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

"Add await" should be upgraded to a codefix in presence of CS4014 #73576

Open
DoctorKrolic opened this issue May 19, 2024 · 0 comments
Open

"Add await" should be upgraded to a codefix in presence of CS4014 #73576

DoctorKrolic opened this issue May 19, 2024 · 0 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@DoctorKrolic
Copy link
Contributor

Currently roslyn provides "Add await" refactoring for cases like this:

async Task<int> GetNumberAsync()
{
    var x = GetNumberAsync()[||];
    return 0;
}

However the same refactoring is provided in cases when compiler raises CS4014 warning about not awaiting a task-returing method inside another async method:

async void M()
{
    [|DoSomethingAsync()|]; // CS4014 here
}

Task DoSomethingAsync() => Task.CompletedTask;

Problems here are:

  • The fix for the diagnostic is not on top of the action list:
    devenv_MdHTywR3BD
  • There is no fix-all. And even if we can add fix-all to refactorings, I want to fix only warning cases, not every place where await can be added

Therefore I think "Add await" should be split into refatoring and a codefix part - it should appear as a codefix with propper fix-all support for cases of CS4014 and just a refactoring in other valid places

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant