dotnet / dotnet/command-line-api
CommandHandler.GetExitCodeAsync only awaits Task<int> return types
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
I believe it would make sense that `GetExitCodeAsync`:
https://github.com/dotnet/command-line-api/blob/a0782c85fd8f7aed16f46935998e9280c86ed2fb/src/System.CommandLine.NamingConventionBinder/CommandHandler.cs#L607
Should await any return object that is a descendant of the `Task` type. If the type is `Task` the `int` value should be returned, otherwise, return 0.
As it stands, an asynchronous method used as a command handler that does not return an `int` is unlikely to run to completion if the System.CommandLine.Hosting code is used.
This can be seen easily in:
https://github.com/dotnet/command-line-api/blob/a0782c85fd8f7aed16f46935998e9280c86ed2fb/samples/HostingPlayground/Program.cs#L36
by adding an `await Task.Delay(TimeSpan.FromSeconds(10));` to force the `Run` method to yield.
Contributor guide
Assessment
This issue has not been assessed yet.