-
Notifications
You must be signed in to change notification settings - Fork 401
Description
Package: System.CommandLine.DragonFruit
Version: 0.4.0-alpha.25306.1
I really enjoy using the DragonFruit library for quickly creating simple console applications—it's been incredibly handy for rapid prototyping and small tools. I was sad to hear about the planned deprecation; hopefully, someone will continue maintaining or carry forward this functionality, as it's extremely useful!
Issue Description
When creating a simple async entry point method (Main
) returning just a Task
, DragonFruit doesn't appear to await the asynchronous operation correctly, causing the application to terminate prematurely.
Example to Reproduce:
public static async Task Main(int number = 1)
{
Console.WriteLine("Running...");
await Task.Delay(TimeSpan.FromSeconds(number));
Console.WriteLine("Finished."); // <-- This line never prints
}
In the above example, the "Finished." message is never displayed, and the program exits immediately after printing "Running...".
Workaround:
Changing the return type from Task
to Task<int>
and returning an explicit integer at the end resolves the issue:
public static async Task<int> Main(int number = 1)
{
Console.WriteLine("Running...");
await Task.Delay(TimeSpan.FromSeconds(number));
Console.WriteLine("Finished."); // <-- Works correctly now
return 0;
}
Expected Behavior
DragonFruit should properly await completion of asynchronous tasks for entry-point methods that return Task
, not just those returning Task<int>
.
Is this a known issue or by-design limitation? Would greatly appreciate guidance or clarification.
Thank you again for your great work on DragonFruit!