commandlineparser / commandlineparser/commandline
WithParsed(async swallows exceptions
- Ngôn ngữ chính
- C#
- Star
- 4.8k
- Fork
- 478
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Some examples of the use of WithParsed / WithParsedAsync with expected behavior
```
internal static class Program
{
private static void Main(string[] args)
{
Parser.Default.ParseArguments(args).WithParsed(_ => throw new Exception());
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
```
internal static class Program
{
private static async Task Main(string[] args)
{
await Parser.Default.ParseArguments(args).WithParsedAsync(_ => throw new Exception());
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
```
internal static class Program
{
private static async Task Main(string[] args)
{
await Parser.Default.ParseArguments(args).WithParsedAsync(async _ =>
{
await Task.CompletedTask; //just for demonstration
throw new Exception();
});
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
### When using WithParsed with an async expresion in a synchrone context, it swallows the exception
```
internal static class Program
{
private static void Main(string[] args)
{
Parser.Default.ParseArguments(args).WithParsed(async _ =>
{
await Task.CompletedTask; //just for demonstration
throw new Exception();
});
```
=> Process finished with exit code 0.
Should also notify about Unhandled exception.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.