AsyncEnumerableEx.Merge doesn't behave the same in all cases
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 798
- PR merge metrics
- No merged PRs in 30d
Description
I think I found a bug, or at least behavior that I wasn't expecting. I'm using `AsyncEnumerableEx.Merge` to try and parallelize a few `IAsyncEnumerable`s. For testing, I'm using this method:
```
static async IAsyncEnumerable Foo(string prefix)
{
var rng = new Random();
Console.WriteLine(prefix);
await Task.Delay(rng.Next(1000, 5000));
yield return $"{prefix} 1";
await Task.Delay(rng.Next(1000, 5000));
yield return $"{prefix} 2";
await Task.Delay(rng.Next(1000, 5000));
yield return $"{prefix} 3";
}
```
When I run it with this:
`return AsyncEnumerableEx.Merge(Foo("a"), Foo("b"), Foo("c"));`
I get the expected output, ordered "a b c" console lines, followed by mixed prefix lines.
However, when I run it with this:
`return AsyncEnumerableEx.Merge(new List { "a", "b", "c" }.Select(x => Foo(x)));`
It blocks, I get a and its prefix lines, then b and its prefix lines, and c then its prefix lines.
I would have expected, perhaps incorrectly, both forms of the method to work the same way.
``
Using `ToList` after the `Select` doesn't seem to work either, but `ToArray` does.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.