dotnet / dotnet/sdk

Refactor CommandBase.Execute to ExecuteAsync

Open
#45,311 0 comments 2 reactions 0 assignees View on GitHub
Area-CLI
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

command implementations which require async operations need to run them synchronously using .GetAwaiter().GetResult() or .Wait()

with ExecuteAsync in CommandBase,

https://github.com/dotnet/sdk/blob/f2ae697b809e488cc52775ca635bbed7e2dbabf4/src/Cli/dotnet/CommandBase.cs#L23

and MainAsync in Cli.Program

https://github.com/dotnet/sdk/blob/f2ae697b809e488cc52775ca635bbed7e2dbabf4/src/Cli/dotnet/Program.cs#L23

it will work for both async (remove .Wait(), .GetAwaiter().GetResult()) and sync (with Task.CompletedTask or Task.FromResult).

n.b. CommandBase.Execute is difference than Task.Execute or ICommand.Execute, both of which should also provide Async variant in principle but that's a separate discussion

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.