dotnet / dotnet/command-line-api
Suggestion: Automatic linkage of CancellationToken in Main parameters to ctrl-C behavior when using Dragonfly
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
This would allow for console apps to neatly just specify that they want to take a CancellationToken, and have it linked to the hosting console's program cancellation behavior automatically.
Usage would look something like
```cs
using System;
namespace DragonFruit
{
class Program
{
///
/// DragonFruit simple example program
///
/// Show verbose output
static async Task Main(
bool verbose,
CancellationToken cancellationToken
)
{
if (verbose)
{
Console.WriteLine("Running in verbose mode");
await BigAsyncTaskLoud(cancellationToken).ConfigureAwait(false);
}
else
{
await BigAsyncTaskQuiet(cancellationToken).ConfigureAwait(false);
}
return 0;
}
}
}
Contributor guide
Research direction
Start by locating the code that binds Main parameters and the existing console Ctrl-C cancellation handling. Check how an async Main accepting a CancellationToken is currently invoked, then define tests for automatic linkage and cancellation during a long-running operation. Done means the shown Main signature receives the hosting cancellation signal without manual setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100