You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When returning a Task from within the AnsiConsole we don't receive back the original task but rather the task of the AnsiConsole. This is fine in 99.99% of cases except for those in which awaiting a task behaves differently to what one would want to do. (e.g Task.WhenAll)
which awaits the resulting task causing the behavior of WhenAll to change
To Reproduce
using System;using System.Threading;using Spectre.Console;async Task DoThing(){await Task.Delay(100);thrownew ApplicationException("Something went wrong");}async Task DoOtherThing(){await Task.Delay(1000);thrownew ApplicationException("Something other went wrong");}varresult= AnsiConsole.Status().StartAsync("Running Test",context =>{return Task.WhenAll(DoThing(), DoOtherThing());});try{await result;}catch(Exceptionex){
AnsiConsole.MarkupLine($"[red]{result.Exception.Message}[/]");return;}
Expected behavior
StartAsync to behave entirely transparently and not change the behavior of the task within.
The expected output of the above repro would be: One or more errors occurred. (Something went wrong) (Something other went wrong)
the actual result however is: One or more errors occurred. (Something went wrong)
Additional context
This relates to a design decision which the dotnet team have made making WhenAll not return the AggregateException when awaited. Instead one must capture the original task and check its exception to get the proper AggregateException.
Describe the bug
When returning a Task from within the AnsiConsole we don't receive back the original task but rather the task of the AnsiConsole. This is fine in 99.99% of cases except for those in which awaiting a task behaves differently to what one would want to do. (e.g Task.WhenAll)
This is due to
spectre.console/src/Spectre.Console/Live/Status/Status.cs
Lines 117 to 121 in b61fff0
which awaits the resulting task causing the behavior of WhenAll to change
To Reproduce
Expected behavior
StartAsync to behave entirely transparently and not change the behavior of the task within.
The expected output of the above repro would be:
One or more errors occurred. (Something went wrong) (Something other went wrong)
the actual result however is:
One or more errors occurred. (Something went wrong)
Additional context
This relates to a design decision which the dotnet team have made making WhenAll not return the AggregateException when awaited. Instead one must capture the original task and check its exception to get the proper AggregateException.
More Context: https://stackoverflow.com/questions/12007781/why-doesnt-await-on-task-whenall-throw-an-aggregateexception
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: