Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 5348 [details]
Test case for Task.WhenAll<T> with empty argument list
When using Task.WhenAll<T> with an empty argument list the returned task never finishes.
This is in conflict with the non-generic Task.WhenAll and also the MSDN documentation: "If the supplied array/enumerable contains no tasks, the returned task will immediately transition to a RanToCompletion state before it's returned to the caller. The returned TResult will be an array of 0 elements."
I've attached a repro case that should be trivial enough to understand without any further documentation :)
Also, fixing it was trivial: https://github.com/mono/mono/pull/799
Explanation: The Task returned by WhenAllCore is normally set to finished state by WhenAllContinuation.Execute(). But when there's no task to be continued, this never gets called and that's it.
The non-generic WhenAllCore has a mechanism that checks for this condition and also if all tasks have already run but that would be harder to implement because the generic version needs to fill the result array. So I think simply testing for an empty input array and returning a finished task object is the simplest solution here.