MinAsync throws InvalidOperationException for empty enumerables
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 798
- PR merge metrics
- No merged PRs in 30d
Description
The documentation of MinAsync only lists `ArgumentNullException` as a possible exception:
https://github.com/dotnet/reactive/blob/f8ddcd6db36f8c9a46880166aae3678ca76bde23/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs#L13-L22
However the method can also throw `InvalidOperationException` if the source contains no elements:
https://github.com/dotnet/reactive/blob/f8ddcd6db36f8c9a46880166aae3678ca76bde23/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs#L78
This behaviour is different from `Enumerable.Min` which returns an nullable type. So the behaviour of this async version is counter-intuitive and it would be good to at least document this exception throwing behaviour. The overload with the property selector has the same issue, and I expect other methods like `MaxAsync` as well.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.